Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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_SPIMD 0x60 /* SPI mode setting */ |
| 58 | #define LOCOMO_SPICT 0x64 /* SPI mode control */ |
| 59 | #define LOCOMO_SPIST 0x68 /* SPI status */ |
| 60 | #define LOCOMO_SPIIS 0x70 /* SPI interrupt status */ |
| 61 | #define LOCOMO_SPIWE 0x74 /* SPI interrupt status write enable */ |
| 62 | #define LOCOMO_SPIIE 0x78 /* SPI interrupt enable */ |
| 63 | #define LOCOMO_SPIIR 0x7c /* SPI interrupt request */ |
| 64 | #define LOCOMO_SPITD 0x80 /* SPI transfer data write */ |
| 65 | #define LOCOMO_SPIRD 0x84 /* SPI receive data read */ |
| 66 | #define LOCOMO_SPITS 0x88 /* SPI transfer data shift */ |
| 67 | #define LOCOMO_SPIRS 0x8C /* SPI receive data shift */ |
| 68 | #define LOCOMO_SPI_TEND (1 << 3) /* Transfer end bit */ |
| 69 | #define LOCOMO_SPI_OVRN (1 << 2) /* Over Run bit */ |
| 70 | #define LOCOMO_SPI_RFW (1 << 1) /* write buffer bit */ |
| 71 | #define LOCOMO_SPI_RFR (1) /* read buffer bit */ |
| 72 | |
| 73 | /* GPIO */ |
| 74 | #define LOCOMO_GPD 0x90 /* GPIO direction */ |
| 75 | #define LOCOMO_GPE 0x94 /* GPIO input enable */ |
| 76 | #define LOCOMO_GPL 0x98 /* GPIO level */ |
| 77 | #define LOCOMO_GPO 0x9c /* GPIO out data setteing */ |
| 78 | #define LOCOMO_GRIE 0xa0 /* GPIO rise detection */ |
| 79 | #define LOCOMO_GFIE 0xa4 /* GPIO fall detection */ |
| 80 | #define LOCOMO_GIS 0xa8 /* GPIO edge detection status */ |
| 81 | #define LOCOMO_GWE 0xac /* GPIO status write enable */ |
| 82 | #define LOCOMO_GIE 0xb0 /* GPIO interrupt enable */ |
| 83 | #define LOCOMO_GIR 0xb4 /* GPIO interrupt request */ |
| 84 | #define LOCOMO_GPIO(Nb) (0x01 << (Nb)) |
| 85 | #define LOCOMO_GPIO_RTS LOCOMO_GPIO(0) |
| 86 | #define LOCOMO_GPIO_CTS LOCOMO_GPIO(1) |
| 87 | #define LOCOMO_GPIO_DSR LOCOMO_GPIO(2) |
| 88 | #define LOCOMO_GPIO_DTR LOCOMO_GPIO(3) |
| 89 | #define LOCOMO_GPIO_LCD_VSHA_ON LOCOMO_GPIO(4) |
| 90 | #define LOCOMO_GPIO_LCD_VSHD_ON LOCOMO_GPIO(5) |
| 91 | #define LOCOMO_GPIO_LCD_VEE_ON LOCOMO_GPIO(6) |
| 92 | #define LOCOMO_GPIO_LCD_MOD LOCOMO_GPIO(7) |
| 93 | #define LOCOMO_GPIO_DAC_ON LOCOMO_GPIO(8) |
| 94 | #define LOCOMO_GPIO_FL_VR LOCOMO_GPIO(9) |
| 95 | #define LOCOMO_GPIO_DAC_SDATA LOCOMO_GPIO(10) |
| 96 | #define LOCOMO_GPIO_DAC_SCK LOCOMO_GPIO(11) |
| 97 | #define LOCOMO_GPIO_DAC_SLOAD LOCOMO_GPIO(12) |
| 98 | |
| 99 | /* Start the definitions of the devices. Each device has an initial |
| 100 | * base address and a series of offsets from that base address. */ |
| 101 | |
| 102 | /* Keyboard controller */ |
| 103 | #define LOCOMO_KEYBOARD 0x40 |
| 104 | #define LOCOMO_KIB 0x00 /* KIB level */ |
| 105 | #define LOCOMO_KSC 0x04 /* KSTRB control */ |
| 106 | #define LOCOMO_KCMD 0x08 /* KSTRB command */ |
| 107 | #define LOCOMO_KIC 0x0c /* Key interrupt */ |
| 108 | |
| 109 | /* Front light adjustment controller */ |
| 110 | #define LOCOMO_FRONTLIGHT 0xc8 |
| 111 | #define LOCOMO_ALS 0x00 /* Adjust light cycle */ |
| 112 | #define LOCOMO_ALD 0x04 /* Adjust light duty */ |
| 113 | |
Richard Purdie | e442378 | 2006-06-26 00:26:27 -0700 | [diff] [blame] | 114 | #define LOCOMO_ALC_EN 0x8000 |
| 115 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | /* Backlight controller: TFT signal */ |
| 117 | #define LOCOMO_BACKLIGHT 0x38 |
| 118 | #define LOCOMO_TC 0x00 /* TFT control signal */ |
| 119 | #define LOCOMO_CPSD 0x04 /* CPS delay */ |
| 120 | |
| 121 | /* Audio controller */ |
| 122 | #define LOCOMO_AUDIO 0x54 |
| 123 | #define LOCOMO_ACC 0x00 /* Audio clock */ |
| 124 | #define LOCOMO_PAIF 0x7C /* PCM audio interface */ |
| 125 | /* Audio clock */ |
| 126 | #define LOCOMO_ACC_XON 0x80 |
| 127 | #define LOCOMO_ACC_XEN 0x40 |
| 128 | #define LOCOMO_ACC_XSEL0 0x00 |
| 129 | #define LOCOMO_ACC_XSEL1 0x20 |
| 130 | #define LOCOMO_ACC_MCLKEN 0x10 |
| 131 | #define LOCOMO_ACC_64FSEN 0x08 |
| 132 | #define LOCOMO_ACC_CLKSEL000 0x00 /* mclk 2 */ |
| 133 | #define LOCOMO_ACC_CLKSEL001 0x01 /* mclk 3 */ |
| 134 | #define LOCOMO_ACC_CLKSEL010 0x02 /* mclk 4 */ |
| 135 | #define LOCOMO_ACC_CLKSEL011 0x03 /* mclk 6 */ |
| 136 | #define LOCOMO_ACC_CLKSEL100 0x04 /* mclk 8 */ |
| 137 | #define LOCOMO_ACC_CLKSEL101 0x05 /* mclk 12 */ |
| 138 | /* PCM audio interface */ |
| 139 | #define LOCOMO_PAIF_SCINV 0x20 |
| 140 | #define LOCOMO_PAIF_SCEN 0x10 |
| 141 | #define LOCOMO_PAIF_LRCRST 0x08 |
| 142 | #define LOCOMO_PAIF_LRCEVE 0x04 |
| 143 | #define LOCOMO_PAIF_LRCINV 0x02 |
| 144 | #define LOCOMO_PAIF_LRCEN 0x01 |
| 145 | |
| 146 | /* LED controller */ |
| 147 | #define LOCOMO_LED 0xe8 |
| 148 | #define LOCOMO_LPT0 0x00 |
| 149 | #define LOCOMO_LPT1 0x04 |
| 150 | /* LED control */ |
| 151 | #define LOCOMO_LPT_TOFH 0x80 |
| 152 | #define LOCOMO_LPT_TOFL 0x08 |
| 153 | #define LOCOMO_LPT_TOH(TOH) ((TOH & 0x7) << 4) |
| 154 | #define LOCOMO_LPT_TOL(TOL) ((TOL & 0x7)) |
| 155 | |
| 156 | extern struct bus_type locomo_bus_type; |
| 157 | |
| 158 | #define LOCOMO_DEVID_KEYBOARD 0 |
| 159 | #define LOCOMO_DEVID_FRONTLIGHT 1 |
| 160 | #define LOCOMO_DEVID_BACKLIGHT 2 |
| 161 | #define LOCOMO_DEVID_AUDIO 3 |
| 162 | #define LOCOMO_DEVID_LED 4 |
| 163 | #define LOCOMO_DEVID_UART 5 |
| 164 | |
| 165 | struct locomo_dev { |
| 166 | struct device dev; |
| 167 | unsigned int devid; |
| 168 | unsigned int irq[1]; |
| 169 | |
| 170 | void *mapbase; |
| 171 | unsigned long length; |
| 172 | |
| 173 | u64 dma_mask; |
| 174 | }; |
| 175 | |
| 176 | #define LOCOMO_DEV(_d) container_of((_d), struct locomo_dev, dev) |
| 177 | |
| 178 | #define locomo_get_drvdata(d) dev_get_drvdata(&(d)->dev) |
| 179 | #define locomo_set_drvdata(d,p) dev_set_drvdata(&(d)->dev, p) |
| 180 | |
| 181 | struct locomo_driver { |
| 182 | struct device_driver drv; |
| 183 | unsigned int devid; |
| 184 | int (*probe)(struct locomo_dev *); |
| 185 | int (*remove)(struct locomo_dev *); |
| 186 | int (*suspend)(struct locomo_dev *, pm_message_t); |
| 187 | int (*resume)(struct locomo_dev *); |
| 188 | }; |
| 189 | |
| 190 | #define LOCOMO_DRV(_d) container_of((_d), struct locomo_driver, drv) |
| 191 | |
| 192 | #define LOCOMO_DRIVER_NAME(_ldev) ((_ldev)->dev.driver->name) |
| 193 | |
| 194 | void locomo_lcd_power(struct locomo_dev *, int, unsigned int); |
| 195 | |
| 196 | int locomo_driver_register(struct locomo_driver *); |
| 197 | void locomo_driver_unregister(struct locomo_driver *); |
| 198 | |
| 199 | /* GPIO control functions */ |
| 200 | void locomo_gpio_set_dir(struct locomo_dev *ldev, unsigned int bits, unsigned int dir); |
| 201 | unsigned int locomo_gpio_read_level(struct locomo_dev *ldev, unsigned int bits); |
| 202 | unsigned int locomo_gpio_read_output(struct locomo_dev *ldev, unsigned int bits); |
| 203 | void locomo_gpio_write(struct locomo_dev *ldev, unsigned int bits, unsigned int set); |
| 204 | |
| 205 | /* M62332 control function */ |
| 206 | void locomo_m62332_senddata(struct locomo_dev *ldev, unsigned int dac_data, int channel); |
| 207 | |
Richard Purdie | e442378 | 2006-06-26 00:26:27 -0700 | [diff] [blame] | 208 | /* Frontlight control */ |
| 209 | void locomo_frontlight_set(struct locomo_dev *dev, int duty, int vr, int bpwf); |
| 210 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | #endif |