1/*
2 * linux/include/asm-arm/hardware/locomo.h
3 *
4 * This file contains the definitions for the LoCoMo G/A Chip
5 *
6 * (C) Copyright 2004 John Lenz
7 *
8 * May be copied or modified under the terms of the GNU General Public
9 * License.  See linux/COPYING for more information.
10 *
11 * Based on sa1111.h
12 */
13#ifndef _ASM_ARCH_LOCOMO
14#define _ASM_ARCH_LOCOMO
15
16#define locomo_writel(val,addr)	({ *(volatile u16 *)(addr) = (val); })
17#define locomo_readl(addr)	(*(volatile u16 *)(addr))
18
19/* LOCOMO version */
20#define LOCOMO_VER	0x00
21
22/* Pin status */
23#define LOCOMO_ST	0x04
24
25/* Pin status */
26#define LOCOMO_C32K	0x08
27
28/* Interrupt controller */
29#define LOCOMO_ICR	0x0C
30
31/* MCS decoder for boot selecting */
32#define LOCOMO_MCSX0	0x10
33#define LOCOMO_MCSX1	0x14
34#define LOCOMO_MCSX2	0x18
35#define LOCOMO_MCSX3	0x1c
36
37/* Touch panel controller */
38#define LOCOMO_ASD	0x20		/* AD start delay */
39#define LOCOMO_HSD	0x28		/* HSYS delay */
40#define LOCOMO_HSC	0x2c		/* HSYS period */
41#define LOCOMO_TADC	0x30		/* tablet ADC clock */
42
43
44/* Long time timer */
45#define LOCOMO_LTC	0xd8		/* LTC interrupt setting */
46#define LOCOMO_LTINT	0xdc		/* LTC interrupt */
47
48/* DAC control signal for LCD (COMADJ ) */
49#define LOCOMO_DAC		0xe0
50/* DAC control */
51#define	LOCOMO_DAC_SCLOEB	0x08	/* SCL pin output data       */
52#define	LOCOMO_DAC_TEST		0x04	/* Test bit                  */
53#define	LOCOMO_DAC_SDA		0x02	/* SDA pin level (read-only) */
54#define	LOCOMO_DAC_SDAOEB	0x01	/* SDA pin output data       */
55
56/* SPI interface */
57#define LOCOMO_SPI	0x60
58#define LOCOMO_SPIMD	0x00		/* SPI mode setting */
59#define LOCOMO_SPICT	0x04		/* SPI mode control */
60#define LOCOMO_SPIST	0x08		/* SPI status */
61#define LOCOMO_SPIIS	0x10		/* SPI interrupt status */
62#define LOCOMO_SPIWE	0x14		/* SPI interrupt status write enable */
63#define LOCOMO_SPIIE	0x18		/* SPI interrupt enable */
64#define LOCOMO_SPIIR	0x1c		/* SPI interrupt request */
65#define LOCOMO_SPITD	0x20		/* SPI transfer data write */
66#define LOCOMO_SPIRD	0x24		/* SPI receive data read */
67#define LOCOMO_SPITS	0x28		/* SPI transfer data shift */
68#define LOCOMO_SPIRS	0x2C		/* SPI receive data shift */
69#define	LOCOMO_SPI_TEND	(1 << 3)	/* Transfer end bit */
70#define	LOCOMO_SPI_OVRN	(1 << 2)	/* Over Run bit */
71#define	LOCOMO_SPI_RFW	(1 << 1)	/* write buffer bit */
72#define	LOCOMO_SPI_RFR	(1)		/* read buffer bit */
73
74/* GPIO */
75#define LOCOMO_GPD		0x90	/* GPIO direction */
76#define LOCOMO_GPE		0x94	/* GPIO input enable */
77#define LOCOMO_GPL		0x98	/* GPIO level */
78#define LOCOMO_GPO		0x9c	/* GPIO out data setteing */
79#define LOCOMO_GRIE		0xa0	/* GPIO rise detection */
80#define LOCOMO_GFIE		0xa4	/* GPIO fall detection */
81#define LOCOMO_GIS		0xa8	/* GPIO edge detection status */
82#define LOCOMO_GWE		0xac	/* GPIO status write enable */
83#define LOCOMO_GIE		0xb0	/* GPIO interrupt enable */
84#define LOCOMO_GIR		0xb4	/* GPIO interrupt request */
85#define	LOCOMO_GPIO(Nb)		(0x01 << (Nb))
86#define LOCOMO_GPIO_RTS		LOCOMO_GPIO(0)
87#define LOCOMO_GPIO_CTS		LOCOMO_GPIO(1)
88#define LOCOMO_GPIO_DSR		LOCOMO_GPIO(2)
89#define LOCOMO_GPIO_DTR		LOCOMO_GPIO(3)
90#define LOCOMO_GPIO_LCD_VSHA_ON	LOCOMO_GPIO(4)
91#define LOCOMO_GPIO_LCD_VSHD_ON	LOCOMO_GPIO(5)
92#define LOCOMO_GPIO_LCD_VEE_ON	LOCOMO_GPIO(6)
93#define LOCOMO_GPIO_LCD_MOD	LOCOMO_GPIO(7)
94#define LOCOMO_GPIO_DAC_ON	LOCOMO_GPIO(8)
95#define LOCOMO_GPIO_FL_VR	LOCOMO_GPIO(9)
96#define LOCOMO_GPIO_DAC_SDATA	LOCOMO_GPIO(10)
97#define LOCOMO_GPIO_DAC_SCK	LOCOMO_GPIO(11)
98#define LOCOMO_GPIO_DAC_SLOAD	LOCOMO_GPIO(12)
99
100/* Start the definitions of the devices.  Each device has an initial
101 * base address and a series of offsets from that base address. */
102
103/* Keyboard controller */
104#define LOCOMO_KEYBOARD		0x40
105#define LOCOMO_KIB		0x00	/* KIB level */
106#define LOCOMO_KSC		0x04	/* KSTRB control */
107#define LOCOMO_KCMD		0x08	/* KSTRB command */
108#define LOCOMO_KIC		0x0c	/* Key interrupt */
109
110/* Front light adjustment controller */
111#define LOCOMO_FRONTLIGHT	0xc8
112#define LOCOMO_ALS		0x00	/* Adjust light cycle */
113#define LOCOMO_ALD		0x04	/* Adjust light duty */
114
115#define LOCOMO_ALC_EN		0x8000
116
117/* Backlight controller: TFT signal */
118#define LOCOMO_BACKLIGHT	0x38
119#define LOCOMO_TC		0x00		/* TFT control signal */
120#define LOCOMO_CPSD		0x04		/* CPS delay */
121
122/* Audio controller */
123#define LOCOMO_AUDIO		0x54
124#define LOCOMO_ACC		0x00	/* Audio clock */
125#define LOCOMO_PAIF		0x7C	/* PCM audio interface */
126/* Audio clock */
127#define	LOCOMO_ACC_XON		0x80
128#define	LOCOMO_ACC_XEN		0x40
129#define	LOCOMO_ACC_XSEL0	0x00
130#define	LOCOMO_ACC_XSEL1	0x20
131#define	LOCOMO_ACC_MCLKEN	0x10
132#define	LOCOMO_ACC_64FSEN	0x08
133#define	LOCOMO_ACC_CLKSEL000	0x00	/* mclk  2 */
134#define	LOCOMO_ACC_CLKSEL001	0x01	/* mclk  3 */
135#define	LOCOMO_ACC_CLKSEL010	0x02	/* mclk  4 */
136#define	LOCOMO_ACC_CLKSEL011	0x03	/* mclk  6 */
137#define	LOCOMO_ACC_CLKSEL100	0x04	/* mclk  8 */
138#define	LOCOMO_ACC_CLKSEL101	0x05	/* mclk 12 */
139/* PCM audio interface */
140#define	LOCOMO_PAIF_SCINV	0x20
141#define	LOCOMO_PAIF_SCEN	0x10
142#define	LOCOMO_PAIF_LRCRST	0x08
143#define	LOCOMO_PAIF_LRCEVE	0x04
144#define	LOCOMO_PAIF_LRCINV	0x02
145#define	LOCOMO_PAIF_LRCEN	0x01
146
147/* LED controller */
148#define LOCOMO_LED		0xe8
149#define LOCOMO_LPT0		0x00
150#define LOCOMO_LPT1		0x04
151/* LED control */
152#define LOCOMO_LPT_TOFH		0x80
153#define LOCOMO_LPT_TOFL		0x08
154#define LOCOMO_LPT_TOH(TOH)	((TOH & 0x7) << 4)
155#define LOCOMO_LPT_TOL(TOL)	((TOL & 0x7))
156
157extern struct bus_type locomo_bus_type;
158
159#define LOCOMO_DEVID_KEYBOARD	0
160#define LOCOMO_DEVID_FRONTLIGHT	1
161#define LOCOMO_DEVID_BACKLIGHT	2
162#define LOCOMO_DEVID_AUDIO	3
163#define LOCOMO_DEVID_LED	4
164#define LOCOMO_DEVID_UART	5
165#define LOCOMO_DEVID_SPI		6
166
167struct locomo_dev {
168	struct device	dev;
169	unsigned int	devid;
170	unsigned int	irq[1];
171
172	void		*mapbase;
173	unsigned long	length;
174
175	u64		dma_mask;
176};
177
178#define LOCOMO_DEV(_d)	container_of((_d), struct locomo_dev, dev)
179
180#define locomo_get_drvdata(d)	dev_get_drvdata(&(d)->dev)
181#define locomo_set_drvdata(d,p)	dev_set_drvdata(&(d)->dev, p)
182
183struct locomo_driver {
184	struct device_driver	drv;
185	unsigned int		devid;
186	int (*probe)(struct locomo_dev *);
187	int (*remove)(struct locomo_dev *);
188	int (*suspend)(struct locomo_dev *, pm_message_t);
189	int (*resume)(struct locomo_dev *);
190};
191
192#define LOCOMO_DRV(_d)	container_of((_d), struct locomo_driver, drv)
193
194#define LOCOMO_DRIVER_NAME(_ldev) ((_ldev)->dev.driver->name)
195
196void locomo_lcd_power(struct locomo_dev *, int, unsigned int);
197
198int locomo_driver_register(struct locomo_driver *);
199void locomo_driver_unregister(struct locomo_driver *);
200
201/* GPIO control functions */
202void locomo_gpio_set_dir(struct device *dev, unsigned int bits, unsigned int dir);
203int locomo_gpio_read_level(struct device *dev, unsigned int bits);
204int locomo_gpio_read_output(struct device *dev, unsigned int bits);
205void locomo_gpio_write(struct device *dev, unsigned int bits, unsigned int set);
206
207
208/* M62332 control function */
209void locomo_m62332_senddata(struct locomo_dev *ldev, unsigned int dac_data, int channel);
210
211/* Frontlight control */
212void locomo_frontlight_set(struct locomo_dev *dev, int duty, int vr, int bpwf);
213
214#endif
215