geode.h (f3a57a60d3e107d17aebb9e52b61c503e5bc14f9) geode.h (c95d1e53ed89b75a4d7b68d1cbae4607b1479243)
1/*
2 * AMD Geode definitions
3 * Copyright (C) 2006, Advanced Micro Devices, Inc.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 2 of the GNU General Public License
7 * as published by the Free Software Foundation.
8 */
9
10#ifndef _ASM_X86_GEODE_H
11#define _ASM_X86_GEODE_H
12
13#include <asm/processor.h>
14#include <linux/io.h>
15#include <linux/cs5535.h>
16
1/*
2 * AMD Geode definitions
3 * Copyright (C) 2006, Advanced Micro Devices, Inc.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 2 of the GNU General Public License
7 * as published by the Free Software Foundation.
8 */
9
10#ifndef _ASM_X86_GEODE_H
11#define _ASM_X86_GEODE_H
12
13#include <asm/processor.h>
14#include <linux/io.h>
15#include <linux/cs5535.h>
16
17/* Generic southbridge functions */
18
19#define GEODE_DEV_PMS 0
20#define GEODE_DEV_ACPI 1
21#define GEODE_DEV_GPIO 2
22#define GEODE_DEV_MFGPT 3
23
24extern int geode_get_dev_base(unsigned int dev);
25
26/* Useful macros */
27#define geode_pms_base() geode_get_dev_base(GEODE_DEV_PMS)
28#define geode_acpi_base() geode_get_dev_base(GEODE_DEV_ACPI)
29#define geode_gpio_base() geode_get_dev_base(GEODE_DEV_GPIO)
30#define geode_mfgpt_base() geode_get_dev_base(GEODE_DEV_MFGPT)
31
32/* MSRS */
33
34#define MSR_LBAR_SMB 0x5140000B
35#define MSR_LBAR_GPIO 0x5140000C
36#define MSR_LBAR_MFGPT 0x5140000D
37#define MSR_LBAR_ACPI 0x5140000E
38#define MSR_LBAR_PMS 0x5140000F
39
40/* Resource Sizes */
41
42#define LBAR_GPIO_SIZE 0xFF
43#define LBAR_MFGPT_SIZE 0x40
44#define LBAR_ACPI_SIZE 0x40
45#define LBAR_PMS_SIZE 0x80
46
47/* ACPI registers (PMS block) */
48
49/*
50 * PM1_EN is only valid when VSA is enabled for 16 bit reads.
51 * When VSA is not enabled, *always* read both PM1_STS and PM1_EN
52 * with a 32 bit read at offset 0x0
53 */
54
55#define PM1_STS 0x00
56#define PM1_EN 0x02
57#define PM1_CNT 0x08
58#define PM2_CNT 0x0C
59#define PM_TMR 0x10
60#define PM_GPE0_STS 0x18
61#define PM_GPE0_EN 0x1C
62
63/* PMC registers (PMS block) */
64
65#define PM_SSD 0x00
66#define PM_SCXA 0x04
67#define PM_SCYA 0x08
68#define PM_OUT_SLPCTL 0x0C
69#define PM_SCLK 0x10
70#define PM_SED 0x1
71#define PM_SCXD 0x18
72#define PM_SCYD 0x1C
73#define PM_IN_SLPCTL 0x20
74#define PM_WKD 0x30
75#define PM_WKXD 0x34
76#define PM_RD 0x38
77#define PM_WKXA 0x3C
78#define PM_FSD 0x40
79#define PM_TSD 0x44
80#define PM_PSD 0x48
81#define PM_NWKD 0x4C
82#define PM_AWKD 0x50
83#define PM_SSC 0x54
84
85static inline u32 geode_gpio(unsigned int nr)
86{
87 BUG_ON(nr > 28);
88 return 1 << nr;
89}
90
91extern void geode_gpio_set(u32, unsigned int);
92extern void geode_gpio_clear(u32, unsigned int);
93extern int geode_gpio_isset(u32, unsigned int);
94extern void geode_gpio_setup_event(unsigned int, int, int);
95extern void geode_gpio_set_irq(unsigned int, unsigned int);
96
97static inline void geode_gpio_event_irq(unsigned int gpio, int pair)
98{
99 geode_gpio_setup_event(gpio, pair, 0);
100}
101
102static inline void geode_gpio_event_pme(unsigned int gpio, int pair)
103{
104 geode_gpio_setup_event(gpio, pair, 1);
105}
106
107/* Specific geode tests */
108
109static inline int is_geode_gx(void)
110{
111 return ((boot_cpu_data.x86_vendor == X86_VENDOR_NSC) &&
112 (boot_cpu_data.x86 == 5) &&
113 (boot_cpu_data.x86_model == 5));
114}
115
116static inline int is_geode_lx(void)
117{
118 return ((boot_cpu_data.x86_vendor == X86_VENDOR_AMD) &&
119 (boot_cpu_data.x86 == 5) &&
120 (boot_cpu_data.x86_model == 10));
121}
122
123static inline int is_geode(void)
124{
125 return (is_geode_gx() || is_geode_lx());
126}
127
17static inline int is_geode_gx(void)
18{
19 return ((boot_cpu_data.x86_vendor == X86_VENDOR_NSC) &&
20 (boot_cpu_data.x86 == 5) &&
21 (boot_cpu_data.x86_model == 5));
22}
23
24static inline int is_geode_lx(void)
25{
26 return ((boot_cpu_data.x86_vendor == X86_VENDOR_AMD) &&
27 (boot_cpu_data.x86 == 5) &&
28 (boot_cpu_data.x86_model == 10));
29}
30
31static inline int is_geode(void)
32{
33 return (is_geode_gx() || is_geode_lx());
34}
35
128static inline void geode_mfgpt_write(int timer, u16 reg, u16 value)
129{
130 u32 base = geode_get_dev_base(GEODE_DEV_MFGPT);
131 outw(value, base + reg + (timer * 8));
132}
133
134static inline u16 geode_mfgpt_read(int timer, u16 reg)
135{
136 u32 base = geode_get_dev_base(GEODE_DEV_MFGPT);
137 return inw(base + reg + (timer * 8));
138}
139
140extern int geode_mfgpt_toggle_event(int timer, int cmp, int event, int enable);
141extern int geode_mfgpt_set_irq(int timer, int cmp, int *irq, int enable);
142extern int geode_mfgpt_alloc_timer(int timer, int domain);
143
144#define geode_mfgpt_setup_irq(t, c, i) geode_mfgpt_set_irq((t), (c), (i), 1)
145#define geode_mfgpt_release_irq(t, c, i) geode_mfgpt_set_irq((t), (c), (i), 0)
146
147#ifdef CONFIG_GEODE_MFGPT_TIMER
148extern int __init mfgpt_timer_setup(void);
149#else
150static inline int mfgpt_timer_setup(void) { return 0; }
151#endif
152
153#endif /* _ASM_X86_GEODE_H */
36#endif /* _ASM_X86_GEODE_H */