14baa9922SRussell King /* 24baa9922SRussell King * arch/arm/include/asm/hardware/locomo.h 34baa9922SRussell King * 44baa9922SRussell King * This file contains the definitions for the LoCoMo G/A Chip 54baa9922SRussell King * 64baa9922SRussell King * (C) Copyright 2004 John Lenz 74baa9922SRussell King * 84baa9922SRussell King * May be copied or modified under the terms of the GNU General Public 94baa9922SRussell King * License. See linux/COPYING for more information. 104baa9922SRussell King * 114baa9922SRussell King * Based on sa1111.h 124baa9922SRussell King */ 134baa9922SRussell King #ifndef _ASM_ARCH_LOCOMO 144baa9922SRussell King #define _ASM_ARCH_LOCOMO 154baa9922SRussell King 164baa9922SRussell King #define locomo_writel(val,addr) ({ *(volatile u16 *)(addr) = (val); }) 174baa9922SRussell King #define locomo_readl(addr) (*(volatile u16 *)(addr)) 184baa9922SRussell King 194baa9922SRussell King /* LOCOMO version */ 204baa9922SRussell King #define LOCOMO_VER 0x00 214baa9922SRussell King 224baa9922SRussell King /* Pin status */ 234baa9922SRussell King #define LOCOMO_ST 0x04 244baa9922SRussell King 254baa9922SRussell King /* Pin status */ 264baa9922SRussell King #define LOCOMO_C32K 0x08 274baa9922SRussell King 284baa9922SRussell King /* Interrupt controller */ 294baa9922SRussell King #define LOCOMO_ICR 0x0C 304baa9922SRussell King 314baa9922SRussell King /* MCS decoder for boot selecting */ 324baa9922SRussell King #define LOCOMO_MCSX0 0x10 334baa9922SRussell King #define LOCOMO_MCSX1 0x14 344baa9922SRussell King #define LOCOMO_MCSX2 0x18 354baa9922SRussell King #define LOCOMO_MCSX3 0x1c 364baa9922SRussell King 374baa9922SRussell King /* Touch panel controller */ 384baa9922SRussell King #define LOCOMO_ASD 0x20 /* AD start delay */ 394baa9922SRussell King #define LOCOMO_HSD 0x28 /* HSYS delay */ 404baa9922SRussell King #define LOCOMO_HSC 0x2c /* HSYS period */ 414baa9922SRussell King #define LOCOMO_TADC 0x30 /* tablet ADC clock */ 424baa9922SRussell King 434baa9922SRussell King 444baa9922SRussell King /* Long time timer */ 454baa9922SRussell King #define LOCOMO_LTC 0xd8 /* LTC interrupt setting */ 464baa9922SRussell King #define LOCOMO_LTINT 0xdc /* LTC interrupt */ 474baa9922SRussell King 484baa9922SRussell King /* DAC control signal for LCD (COMADJ ) */ 494baa9922SRussell King #define LOCOMO_DAC 0xe0 504baa9922SRussell King /* DAC control */ 514baa9922SRussell King #define LOCOMO_DAC_SCLOEB 0x08 /* SCL pin output data */ 524baa9922SRussell King #define LOCOMO_DAC_TEST 0x04 /* Test bit */ 534baa9922SRussell King #define LOCOMO_DAC_SDA 0x02 /* SDA pin level (read-only) */ 544baa9922SRussell King #define LOCOMO_DAC_SDAOEB 0x01 /* SDA pin output data */ 554baa9922SRussell King 564baa9922SRussell King /* SPI interface */ 574baa9922SRussell King #define LOCOMO_SPI 0x60 584baa9922SRussell King #define LOCOMO_SPIMD 0x00 /* SPI mode setting */ 594baa9922SRussell King #define LOCOMO_SPICT 0x04 /* SPI mode control */ 604baa9922SRussell King #define LOCOMO_SPIST 0x08 /* SPI status */ 614baa9922SRussell King #define LOCOMO_SPI_TEND (1 << 3) /* Transfer end bit */ 624baa9922SRussell King #define LOCOMO_SPI_REND (1 << 2) /* Receive end bit */ 634baa9922SRussell King #define LOCOMO_SPI_RFW (1 << 1) /* write buffer bit */ 644baa9922SRussell King #define LOCOMO_SPI_RFR (1) /* read buffer bit */ 654baa9922SRussell King 664baa9922SRussell King #define LOCOMO_SPIIS 0x10 /* SPI interrupt status */ 674baa9922SRussell King #define LOCOMO_SPIWE 0x14 /* SPI interrupt status write enable */ 684baa9922SRussell King #define LOCOMO_SPIIE 0x18 /* SPI interrupt enable */ 694baa9922SRussell King #define LOCOMO_SPIIR 0x1c /* SPI interrupt request */ 704baa9922SRussell King #define LOCOMO_SPITD 0x20 /* SPI transfer data write */ 714baa9922SRussell King #define LOCOMO_SPIRD 0x24 /* SPI receive data read */ 724baa9922SRussell King #define LOCOMO_SPITS 0x28 /* SPI transfer data shift */ 734baa9922SRussell King #define LOCOMO_SPIRS 0x2C /* SPI receive data shift */ 744baa9922SRussell King 754baa9922SRussell King /* GPIO */ 764baa9922SRussell King #define LOCOMO_GPD 0x90 /* GPIO direction */ 774baa9922SRussell King #define LOCOMO_GPE 0x94 /* GPIO input enable */ 784baa9922SRussell King #define LOCOMO_GPL 0x98 /* GPIO level */ 794baa9922SRussell King #define LOCOMO_GPO 0x9c /* GPIO out data setting */ 804baa9922SRussell King #define LOCOMO_GRIE 0xa0 /* GPIO rise detection */ 814baa9922SRussell King #define LOCOMO_GFIE 0xa4 /* GPIO fall detection */ 824baa9922SRussell King #define LOCOMO_GIS 0xa8 /* GPIO edge detection status */ 834baa9922SRussell King #define LOCOMO_GWE 0xac /* GPIO status write enable */ 844baa9922SRussell King #define LOCOMO_GIE 0xb0 /* GPIO interrupt enable */ 854baa9922SRussell King #define LOCOMO_GIR 0xb4 /* GPIO interrupt request */ 864baa9922SRussell King #define LOCOMO_GPIO(Nb) (0x01 << (Nb)) 874baa9922SRussell King #define LOCOMO_GPIO_RTS LOCOMO_GPIO(0) 884baa9922SRussell King #define LOCOMO_GPIO_CTS LOCOMO_GPIO(1) 894baa9922SRussell King #define LOCOMO_GPIO_DSR LOCOMO_GPIO(2) 904baa9922SRussell King #define LOCOMO_GPIO_DTR LOCOMO_GPIO(3) 914baa9922SRussell King #define LOCOMO_GPIO_LCD_VSHA_ON LOCOMO_GPIO(4) 924baa9922SRussell King #define LOCOMO_GPIO_LCD_VSHD_ON LOCOMO_GPIO(5) 934baa9922SRussell King #define LOCOMO_GPIO_LCD_VEE_ON LOCOMO_GPIO(6) 944baa9922SRussell King #define LOCOMO_GPIO_LCD_MOD LOCOMO_GPIO(7) 954baa9922SRussell King #define LOCOMO_GPIO_DAC_ON LOCOMO_GPIO(8) 964baa9922SRussell King #define LOCOMO_GPIO_FL_VR LOCOMO_GPIO(9) 974baa9922SRussell King #define LOCOMO_GPIO_DAC_SDATA LOCOMO_GPIO(10) 984baa9922SRussell King #define LOCOMO_GPIO_DAC_SCK LOCOMO_GPIO(11) 994baa9922SRussell King #define LOCOMO_GPIO_DAC_SLOAD LOCOMO_GPIO(12) 1004baa9922SRussell King #define LOCOMO_GPIO_CARD_DETECT LOCOMO_GPIO(13) 1014baa9922SRussell King #define LOCOMO_GPIO_WRITE_PROT LOCOMO_GPIO(14) 1024baa9922SRussell King #define LOCOMO_GPIO_CARD_POWER LOCOMO_GPIO(15) 1034baa9922SRussell King 1044baa9922SRussell King /* Start the definitions of the devices. Each device has an initial 1054baa9922SRussell King * base address and a series of offsets from that base address. */ 1064baa9922SRussell King 1074baa9922SRussell King /* Keyboard controller */ 1084baa9922SRussell King #define LOCOMO_KEYBOARD 0x40 1094baa9922SRussell King #define LOCOMO_KIB 0x00 /* KIB level */ 1104baa9922SRussell King #define LOCOMO_KSC 0x04 /* KSTRB control */ 1114baa9922SRussell King #define LOCOMO_KCMD 0x08 /* KSTRB command */ 1124baa9922SRussell King #define LOCOMO_KIC 0x0c /* Key interrupt */ 1134baa9922SRussell King 1144baa9922SRussell King /* Front light adjustment controller */ 1154baa9922SRussell King #define LOCOMO_FRONTLIGHT 0xc8 1164baa9922SRussell King #define LOCOMO_ALS 0x00 /* Adjust light cycle */ 1174baa9922SRussell King #define LOCOMO_ALD 0x04 /* Adjust light duty */ 1184baa9922SRussell King 1194baa9922SRussell King #define LOCOMO_ALC_EN 0x8000 1204baa9922SRussell King 1214baa9922SRussell King /* Backlight controller: TFT signal */ 1224baa9922SRussell King #define LOCOMO_BACKLIGHT 0x38 1234baa9922SRussell King #define LOCOMO_TC 0x00 /* TFT control signal */ 1244baa9922SRussell King #define LOCOMO_CPSD 0x04 /* CPS delay */ 1254baa9922SRussell King 1264baa9922SRussell King /* Audio controller */ 1274baa9922SRussell King #define LOCOMO_AUDIO 0x54 1284baa9922SRussell King #define LOCOMO_ACC 0x00 /* Audio clock */ 1294baa9922SRussell King #define LOCOMO_PAIF 0xD0 /* PCM audio interface */ 1304baa9922SRussell King /* Audio clock */ 1314baa9922SRussell King #define LOCOMO_ACC_XON 0x80 1324baa9922SRussell King #define LOCOMO_ACC_XEN 0x40 1334baa9922SRussell King #define LOCOMO_ACC_XSEL0 0x00 1344baa9922SRussell King #define LOCOMO_ACC_XSEL1 0x20 1354baa9922SRussell King #define LOCOMO_ACC_MCLKEN 0x10 1364baa9922SRussell King #define LOCOMO_ACC_64FSEN 0x08 1374baa9922SRussell King #define LOCOMO_ACC_CLKSEL000 0x00 /* mclk 2 */ 1384baa9922SRussell King #define LOCOMO_ACC_CLKSEL001 0x01 /* mclk 3 */ 1394baa9922SRussell King #define LOCOMO_ACC_CLKSEL010 0x02 /* mclk 4 */ 1404baa9922SRussell King #define LOCOMO_ACC_CLKSEL011 0x03 /* mclk 6 */ 1414baa9922SRussell King #define LOCOMO_ACC_CLKSEL100 0x04 /* mclk 8 */ 1424baa9922SRussell King #define LOCOMO_ACC_CLKSEL101 0x05 /* mclk 12 */ 1434baa9922SRussell King /* PCM audio interface */ 1444baa9922SRussell King #define LOCOMO_PAIF_SCINV 0x20 1454baa9922SRussell King #define LOCOMO_PAIF_SCEN 0x10 1464baa9922SRussell King #define LOCOMO_PAIF_LRCRST 0x08 1474baa9922SRussell King #define LOCOMO_PAIF_LRCEVE 0x04 1484baa9922SRussell King #define LOCOMO_PAIF_LRCINV 0x02 1494baa9922SRussell King #define LOCOMO_PAIF_LRCEN 0x01 1504baa9922SRussell King 1514baa9922SRussell King /* LED controller */ 1524baa9922SRussell King #define LOCOMO_LED 0xe8 1534baa9922SRussell King #define LOCOMO_LPT0 0x00 1544baa9922SRussell King #define LOCOMO_LPT1 0x04 1554baa9922SRussell King /* LED control */ 1564baa9922SRussell King #define LOCOMO_LPT_TOFH 0x80 1574baa9922SRussell King #define LOCOMO_LPT_TOFL 0x08 1584baa9922SRussell King #define LOCOMO_LPT_TOH(TOH) ((TOH & 0x7) << 4) 1594baa9922SRussell King #define LOCOMO_LPT_TOL(TOL) ((TOL & 0x7)) 1604baa9922SRussell King 1614baa9922SRussell King extern struct bus_type locomo_bus_type; 1624baa9922SRussell King 1634baa9922SRussell King #define LOCOMO_DEVID_KEYBOARD 0 1644baa9922SRussell King #define LOCOMO_DEVID_FRONTLIGHT 1 1654baa9922SRussell King #define LOCOMO_DEVID_BACKLIGHT 2 1664baa9922SRussell King #define LOCOMO_DEVID_AUDIO 3 1674baa9922SRussell King #define LOCOMO_DEVID_LED 4 1684baa9922SRussell King #define LOCOMO_DEVID_UART 5 1694baa9922SRussell King #define LOCOMO_DEVID_SPI 6 1704baa9922SRussell King 1714baa9922SRussell King struct locomo_dev { 1724baa9922SRussell King struct device dev; 1734baa9922SRussell King unsigned int devid; 1744baa9922SRussell King unsigned int irq[1]; 1754baa9922SRussell King 1764baa9922SRussell King void *mapbase; 1774baa9922SRussell King unsigned long length; 1784baa9922SRussell King 1794baa9922SRussell King u64 dma_mask; 1804baa9922SRussell King }; 1814baa9922SRussell King 1824baa9922SRussell King #define LOCOMO_DEV(_d) container_of((_d), struct locomo_dev, dev) 1834baa9922SRussell King 1844baa9922SRussell King #define locomo_get_drvdata(d) dev_get_drvdata(&(d)->dev) 1854baa9922SRussell King #define locomo_set_drvdata(d,p) dev_set_drvdata(&(d)->dev, p) 1864baa9922SRussell King 1874baa9922SRussell King struct locomo_driver { 1884baa9922SRussell King struct device_driver drv; 1894baa9922SRussell King unsigned int devid; 1904baa9922SRussell King int (*probe)(struct locomo_dev *); 19133d6d2bbSUwe Kleine-König void (*remove)(struct locomo_dev *); 1924baa9922SRussell King }; 1934baa9922SRussell King 1944baa9922SRussell King #define LOCOMO_DRV(_d) container_of((_d), struct locomo_driver, drv) 1954baa9922SRussell King 1964baa9922SRussell King #define LOCOMO_DRIVER_NAME(_ldev) ((_ldev)->dev.driver->name) 1974baa9922SRussell King 198*5e8a380bSArnd Bergmann extern void locomolcd_power(int on); 1994baa9922SRussell King 2004baa9922SRussell King int locomo_driver_register(struct locomo_driver *); 2014baa9922SRussell King void locomo_driver_unregister(struct locomo_driver *); 2024baa9922SRussell King 2034baa9922SRussell King /* GPIO control functions */ 2044baa9922SRussell King void locomo_gpio_set_dir(struct device *dev, unsigned int bits, unsigned int dir); 2054baa9922SRussell King int locomo_gpio_read_level(struct device *dev, unsigned int bits); 2064baa9922SRussell King int locomo_gpio_read_output(struct device *dev, unsigned int bits); 2074baa9922SRussell King void locomo_gpio_write(struct device *dev, unsigned int bits, unsigned int set); 2084baa9922SRussell King 2094baa9922SRussell King /* M62332 control function */ 2104baa9922SRussell King void locomo_m62332_senddata(struct locomo_dev *ldev, unsigned int dac_data, int channel); 2114baa9922SRussell King 2124baa9922SRussell King /* Frontlight control */ 2134baa9922SRussell King void locomo_frontlight_set(struct locomo_dev *dev, int duty, int vr, int bpwf); 2144baa9922SRussell King 215ac609d26SEric Miao struct locomo_platform_data { 216ac609d26SEric Miao int irq_base; /* IRQ base for cascaded on-chip IRQs */ 217ac609d26SEric Miao }; 218ac609d26SEric Miao 2194baa9922SRussell King #endif 220