locomo.h 7.1 KB

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