Path: blob/master/arch/arm/mach-omap1/board-palmz71.c
10817 views
/*1* linux/arch/arm/mach-omap1/board-palmz71.c2*3* Modified from board-generic.c4*5* Support for the Palm Zire71 PDA.6*7* Original version : Laurent Gonzalez8*9* Modified for zire71 : Marek Vasut10*11* This program is free software; you can redistribute it and/or modify12* it under the terms of the GNU General Public License version 2 as13* published by the Free Software Foundation.14*/1516#include <linux/delay.h>17#include <linux/kernel.h>18#include <linux/init.h>19#include <linux/platform_device.h>20#include <linux/notifier.h>21#include <linux/clk.h>22#include <linux/irq.h>23#include <linux/input.h>24#include <linux/interrupt.h>25#include <linux/mtd/mtd.h>26#include <linux/mtd/partitions.h>27#include <linux/mtd/physmap.h>2829#include <mach/hardware.h>30#include <asm/mach-types.h>31#include <asm/mach/arch.h>32#include <asm/mach/map.h>3334#include <mach/gpio.h>35#include <plat/flash.h>36#include <plat/mux.h>37#include <plat/usb.h>38#include <plat/dma.h>39#include <plat/tc.h>40#include <plat/board.h>41#include <plat/irda.h>42#include <plat/keypad.h>43#include <plat/common.h>44#include <plat/omap-alsa.h>4546#include <linux/spi/spi.h>47#include <linux/spi/ads7846.h>4849#define PALMZ71_USBDETECT_GPIO 050#define PALMZ71_PENIRQ_GPIO 651#define PALMZ71_MMC_WP_GPIO 852#define PALMZ71_HDQ_GPIO 115354#define PALMZ71_HOTSYNC_GPIO OMAP_MPUIO(1)55#define PALMZ71_CABLE_GPIO OMAP_MPUIO(2)56#define PALMZ71_SLIDER_GPIO OMAP_MPUIO(3)57#define PALMZ71_MMC_IN_GPIO OMAP_MPUIO(4)5859static void __init60omap_palmz71_init_irq(void)61{62omap1_init_common_hw();63omap_init_irq();64}6566static const unsigned int palmz71_keymap[] = {67KEY(0, 0, KEY_F1),68KEY(1, 0, KEY_F2),69KEY(2, 0, KEY_F3),70KEY(3, 0, KEY_F4),71KEY(4, 0, KEY_POWER),72KEY(0, 1, KEY_LEFT),73KEY(1, 1, KEY_DOWN),74KEY(2, 1, KEY_UP),75KEY(3, 1, KEY_RIGHT),76KEY(4, 1, KEY_ENTER),77KEY(0, 2, KEY_CAMERA),78};7980static const struct matrix_keymap_data palmz71_keymap_data = {81.keymap = palmz71_keymap,82.keymap_size = ARRAY_SIZE(palmz71_keymap),83};8485static struct omap_kp_platform_data palmz71_kp_data = {86.rows = 8,87.cols = 8,88.keymap_data = &palmz71_keymap_data,89.rep = true,90.delay = 80,91};9293static struct resource palmz71_kp_resources[] = {94[0] = {95.start = INT_KEYBOARD,96.end = INT_KEYBOARD,97.flags = IORESOURCE_IRQ,98},99};100101static struct platform_device palmz71_kp_device = {102.name = "omap-keypad",103.id = -1,104.dev = {105.platform_data = &palmz71_kp_data,106},107.num_resources = ARRAY_SIZE(palmz71_kp_resources),108.resource = palmz71_kp_resources,109};110111static struct mtd_partition palmz71_rom_partitions[] = {112/* PalmOS "Small ROM", contains the bootloader and the debugger */113{114.name = "smallrom",115.offset = 0,116.size = 0xa000,117.mask_flags = MTD_WRITEABLE,118},119/* PalmOS "Big ROM", a filesystem with all the OS code and data */120{121.name = "bigrom",122.offset = SZ_128K,123/*124* 0x5f0000 bytes big in the multi-language ("EFIGS") version,125* 0x7b0000 bytes in the English-only ("enUS") version.126*/127.size = 0x7b0000,128.mask_flags = MTD_WRITEABLE,129},130};131132static struct physmap_flash_data palmz71_rom_data = {133.width = 2,134.set_vpp = omap1_set_vpp,135.parts = palmz71_rom_partitions,136.nr_parts = ARRAY_SIZE(palmz71_rom_partitions),137};138139static struct resource palmz71_rom_resource = {140.start = OMAP_CS0_PHYS,141.end = OMAP_CS0_PHYS + SZ_8M - 1,142.flags = IORESOURCE_MEM,143};144145static struct platform_device palmz71_rom_device = {146.name = "physmap-flash",147.id = -1,148.dev = {149.platform_data = &palmz71_rom_data,150},151.num_resources = 1,152.resource = &palmz71_rom_resource,153};154155static struct platform_device palmz71_lcd_device = {156.name = "lcd_palmz71",157.id = -1,158};159160static struct omap_irda_config palmz71_irda_config = {161.transceiver_cap = IR_SIRMODE,162.rx_channel = OMAP_DMA_UART3_RX,163.tx_channel = OMAP_DMA_UART3_TX,164.dest_start = UART3_THR,165.src_start = UART3_RHR,166.tx_trigger = 0,167.rx_trigger = 0,168};169170static struct resource palmz71_irda_resources[] = {171[0] = {172.start = INT_UART3,173.end = INT_UART3,174.flags = IORESOURCE_IRQ,175},176};177178static struct platform_device palmz71_irda_device = {179.name = "omapirda",180.id = -1,181.dev = {182.platform_data = &palmz71_irda_config,183},184.num_resources = ARRAY_SIZE(palmz71_irda_resources),185.resource = palmz71_irda_resources,186};187188static struct platform_device palmz71_spi_device = {189.name = "spi_palmz71",190.id = -1,191};192193static struct omap_backlight_config palmz71_backlight_config = {194.default_intensity = 0xa0,195};196197static struct platform_device palmz71_backlight_device = {198.name = "omap-bl",199.id = -1,200.dev = {201.platform_data = &palmz71_backlight_config,202},203};204205static struct platform_device *devices[] __initdata = {206&palmz71_rom_device,207&palmz71_kp_device,208&palmz71_lcd_device,209&palmz71_irda_device,210&palmz71_spi_device,211&palmz71_backlight_device,212};213214static int215palmz71_get_pendown_state(void)216{217return !gpio_get_value(PALMZ71_PENIRQ_GPIO);218}219220static const struct ads7846_platform_data palmz71_ts_info = {221.model = 7846,222.vref_delay_usecs = 100, /* internal, no capacitor */223.x_plate_ohms = 419,224.y_plate_ohms = 486,225.get_pendown_state = palmz71_get_pendown_state,226};227228static struct spi_board_info __initdata palmz71_boardinfo[] = { {229/* MicroWire (bus 2) CS0 has an ads7846e */230.modalias = "ads7846",231.platform_data = &palmz71_ts_info,232.irq = OMAP_GPIO_IRQ(PALMZ71_PENIRQ_GPIO),233.max_speed_hz = 120000 /* max sample rate at 3V */234* 26 /* command + data + overhead */,235.bus_num = 2,236.chip_select = 0,237} };238239static struct omap_usb_config palmz71_usb_config __initdata = {240.register_dev = 1, /* Mini-B only receptacle */241.hmc_mode = 0,242.pins[0] = 2,243};244245static struct omap_lcd_config palmz71_lcd_config __initdata = {246.ctrl_name = "internal",247};248249static struct omap_board_config_kernel palmz71_config[] __initdata = {250{OMAP_TAG_LCD, &palmz71_lcd_config},251};252253static irqreturn_t254palmz71_powercable(int irq, void *dev_id)255{256if (gpio_get_value(PALMZ71_USBDETECT_GPIO)) {257printk(KERN_INFO "PM: Power cable connected\n");258irq_set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO),259IRQ_TYPE_EDGE_FALLING);260} else {261printk(KERN_INFO "PM: Power cable disconnected\n");262irq_set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO),263IRQ_TYPE_EDGE_RISING);264}265return IRQ_HANDLED;266}267268static void __init269omap_mpu_wdt_mode(int mode)270{271if (mode)272omap_writew(0x8000, OMAP_WDT_TIMER_MODE);273else {274omap_writew(0x00f5, OMAP_WDT_TIMER_MODE);275omap_writew(0x00a0, OMAP_WDT_TIMER_MODE);276}277}278279static void __init280palmz71_gpio_setup(int early)281{282if (early) {283/* Only set GPIO1 so we have a working serial */284gpio_direction_output(1, 1);285} else {286/* Set MMC/SD host WP pin as input */287if (gpio_request(PALMZ71_MMC_WP_GPIO, "MMC WP") < 0) {288printk(KERN_ERR "Could not reserve WP GPIO!\n");289return;290}291gpio_direction_input(PALMZ71_MMC_WP_GPIO);292293/* Monitor the Power-cable-connected signal */294if (gpio_request(PALMZ71_USBDETECT_GPIO, "USB detect") < 0) {295printk(KERN_ERR296"Could not reserve cable signal GPIO!\n");297return;298}299gpio_direction_input(PALMZ71_USBDETECT_GPIO);300if (request_irq(gpio_to_irq(PALMZ71_USBDETECT_GPIO),301palmz71_powercable, IRQF_SAMPLE_RANDOM,302"palmz71-cable", 0))303printk(KERN_ERR304"IRQ request for power cable failed!\n");305palmz71_powercable(gpio_to_irq(PALMZ71_USBDETECT_GPIO), 0);306}307}308309static void __init310omap_palmz71_init(void)311{312/* mux pins for uarts */313omap_cfg_reg(UART1_TX);314omap_cfg_reg(UART1_RTS);315omap_cfg_reg(UART2_TX);316omap_cfg_reg(UART2_RTS);317omap_cfg_reg(UART3_TX);318omap_cfg_reg(UART3_RX);319320palmz71_gpio_setup(1);321omap_mpu_wdt_mode(0);322323omap_board_config = palmz71_config;324omap_board_config_size = ARRAY_SIZE(palmz71_config);325326platform_add_devices(devices, ARRAY_SIZE(devices));327328spi_register_board_info(palmz71_boardinfo,329ARRAY_SIZE(palmz71_boardinfo));330omap1_usb_init(&palmz71_usb_config);331omap_serial_init();332omap_register_i2c_bus(1, 100, NULL, 0);333palmz71_gpio_setup(0);334}335336static void __init337omap_palmz71_map_io(void)338{339omap1_map_common_io();340}341342MACHINE_START(OMAP_PALMZ71, "OMAP310 based Palm Zire71")343.boot_params = 0x10000100,344.map_io = omap_palmz71_map_io,345.reserve = omap_reserve,346.init_irq = omap_palmz71_init_irq,347.init_machine = omap_palmz71_init,348.timer = &omap_timer,349MACHINE_END350351352