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 | |
| 114 | /* Backlight controller: TFT signal */ |
| 115 | #define LOCOMO_BACKLIGHT 0x38 |
| 116 | #define LOCOMO_TC 0x00 /* TFT control signal */ |
| 117 | #define LOCOMO_CPSD 0x04 /* CPS delay */ |
| 118 | |
| 119 | /* Audio controller */ |
| 120 | #define LOCOMO_AUDIO 0x54 |
| 121 | #define LOCOMO_ACC 0x00 /* Audio clock */ |
| 122 | #define LOCOMO_PAIF 0x7C /* PCM audio interface */ |
| 123 | /* Audio clock */ |
| 124 | #define LOCOMO_ACC_XON 0x80 |
| 125 | #define LOCOMO_ACC_XEN 0x40 |
| 126 | #define LOCOMO_ACC_XSEL0 0x00 |
| 127 | #define LOCOMO_ACC_XSEL1 0x20 |
| 128 | #define LOCOMO_ACC_MCLKEN 0x10 |
| 129 | #define LOCOMO_ACC_64FSEN 0x08 |
| 130 | #define LOCOMO_ACC_CLKSEL000 0x00 /* mclk 2 */ |
| 131 | #define LOCOMO_ACC_CLKSEL001 0x01 /* mclk 3 */ |
| 132 | #define LOCOMO_ACC_CLKSEL010 0x02 /* mclk 4 */ |
| 133 | #define LOCOMO_ACC_CLKSEL011 0x03 /* mclk 6 */ |
| 134 | #define LOCOMO_ACC_CLKSEL100 0x04 /* mclk 8 */ |
| 135 | #define LOCOMO_ACC_CLKSEL101 0x05 /* mclk 12 */ |
| 136 | /* PCM audio interface */ |
| 137 | #define LOCOMO_PAIF_SCINV 0x20 |
| 138 | #define LOCOMO_PAIF_SCEN 0x10 |
| 139 | #define LOCOMO_PAIF_LRCRST 0x08 |
| 140 | #define LOCOMO_PAIF_LRCEVE 0x04 |
| 141 | #define LOCOMO_PAIF_LRCINV 0x02 |
| 142 | #define LOCOMO_PAIF_LRCEN 0x01 |
| 143 | |
| 144 | /* LED controller */ |
| 145 | #define LOCOMO_LED 0xe8 |
| 146 | #define LOCOMO_LPT0 0x00 |
| 147 | #define LOCOMO_LPT1 0x04 |
| 148 | /* LED control */ |
| 149 | #define LOCOMO_LPT_TOFH 0x80 |
| 150 | #define LOCOMO_LPT_TOFL 0x08 |
| 151 | #define LOCOMO_LPT_TOH(TOH) ((TOH & 0x7) << 4) |
| 152 | #define LOCOMO_LPT_TOL(TOL) ((TOL & 0x7)) |
| 153 | |
| 154 | extern struct bus_type locomo_bus_type; |
| 155 | |
| 156 | #define LOCOMO_DEVID_KEYBOARD 0 |
| 157 | #define LOCOMO_DEVID_FRONTLIGHT 1 |
| 158 | #define LOCOMO_DEVID_BACKLIGHT 2 |
| 159 | #define LOCOMO_DEVID_AUDIO 3 |
| 160 | #define LOCOMO_DEVID_LED 4 |
| 161 | #define LOCOMO_DEVID_UART 5 |
| 162 | |
| 163 | struct locomo_dev { |
| 164 | struct device dev; |
| 165 | unsigned int devid; |
| 166 | unsigned int irq[1]; |
| 167 | |
| 168 | void *mapbase; |
| 169 | unsigned long length; |
| 170 | |
| 171 | u64 dma_mask; |
| 172 | }; |
| 173 | |
| 174 | #define LOCOMO_DEV(_d) container_of((_d), struct locomo_dev, dev) |
| 175 | |
| 176 | #define locomo_get_drvdata(d) dev_get_drvdata(&(d)->dev) |
| 177 | #define locomo_set_drvdata(d,p) dev_set_drvdata(&(d)->dev, p) |
| 178 | |
| 179 | struct locomo_driver { |
| 180 | struct device_driver drv; |
| 181 | unsigned int devid; |
| 182 | int (*probe)(struct locomo_dev *); |
| 183 | int (*remove)(struct locomo_dev *); |
| 184 | int (*suspend)(struct locomo_dev *, pm_message_t); |
| 185 | int (*resume)(struct locomo_dev *); |
| 186 | }; |
| 187 | |
| 188 | #define LOCOMO_DRV(_d) container_of((_d), struct locomo_driver, drv) |
| 189 | |
| 190 | #define LOCOMO_DRIVER_NAME(_ldev) ((_ldev)->dev.driver->name) |
| 191 | |
| 192 | void locomo_lcd_power(struct locomo_dev *, int, unsigned int); |
| 193 | |
| 194 | int locomo_driver_register(struct locomo_driver *); |
| 195 | void locomo_driver_unregister(struct locomo_driver *); |
| 196 | |
| 197 | /* GPIO control functions */ |
| 198 | void locomo_gpio_set_dir(struct locomo_dev *ldev, unsigned int bits, unsigned int dir); |
| 199 | unsigned int locomo_gpio_read_level(struct locomo_dev *ldev, unsigned int bits); |
| 200 | unsigned int locomo_gpio_read_output(struct locomo_dev *ldev, unsigned int bits); |
| 201 | void locomo_gpio_write(struct locomo_dev *ldev, unsigned int bits, unsigned int set); |
| 202 | |
| 203 | /* M62332 control function */ |
| 204 | void locomo_m62332_senddata(struct locomo_dev *ldev, unsigned int dac_data, int channel); |
| 205 | |
| 206 | #endif |