Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * linux/arch/arm/mach-omap1/board-palmz71.c
0004  *
0005  * Modified from board-generic.c
0006  *
0007  * Support for the Palm Zire71 PDA.
0008  *
0009  * Original version : Laurent Gonzalez
0010  *
0011  * Modified for zire71 : Marek Vasut
0012  */
0013 
0014 #include <linux/delay.h>
0015 #include <linux/gpio.h>
0016 #include <linux/kernel.h>
0017 #include <linux/init.h>
0018 #include <linux/platform_device.h>
0019 #include <linux/notifier.h>
0020 #include <linux/clk.h>
0021 #include <linux/irq.h>
0022 #include <linux/input.h>
0023 #include <linux/interrupt.h>
0024 #include <linux/mtd/mtd.h>
0025 #include <linux/mtd/partitions.h>
0026 #include <linux/mtd/physmap.h>
0027 #include <linux/omapfb.h>
0028 #include <linux/spi/spi.h>
0029 #include <linux/spi/ads7846.h>
0030 #include <linux/platform_data/omap1_bl.h>
0031 #include <linux/platform_data/keypad-omap.h>
0032 #include <linux/omap-dma.h>
0033 
0034 #include <asm/mach-types.h>
0035 #include <asm/mach/arch.h>
0036 #include <asm/mach/map.h>
0037 
0038 #include "tc.h"
0039 #include "flash.h"
0040 #include "mux.h"
0041 #include "hardware.h"
0042 #include "usb.h"
0043 #include "common.h"
0044 
0045 #define PALMZ71_USBDETECT_GPIO  0
0046 #define PALMZ71_PENIRQ_GPIO 6
0047 #define PALMZ71_MMC_WP_GPIO 8
0048 #define PALMZ71_HDQ_GPIO    11
0049 
0050 #define PALMZ71_HOTSYNC_GPIO    OMAP_MPUIO(1)
0051 #define PALMZ71_CABLE_GPIO  OMAP_MPUIO(2)
0052 #define PALMZ71_SLIDER_GPIO OMAP_MPUIO(3)
0053 #define PALMZ71_MMC_IN_GPIO OMAP_MPUIO(4)
0054 
0055 static const unsigned int palmz71_keymap[] = {
0056     KEY(0, 0, KEY_F1),
0057     KEY(1, 0, KEY_F2),
0058     KEY(2, 0, KEY_F3),
0059     KEY(3, 0, KEY_F4),
0060     KEY(4, 0, KEY_POWER),
0061     KEY(0, 1, KEY_LEFT),
0062     KEY(1, 1, KEY_DOWN),
0063     KEY(2, 1, KEY_UP),
0064     KEY(3, 1, KEY_RIGHT),
0065     KEY(4, 1, KEY_ENTER),
0066     KEY(0, 2, KEY_CAMERA),
0067 };
0068 
0069 static const struct matrix_keymap_data palmz71_keymap_data = {
0070     .keymap     = palmz71_keymap,
0071     .keymap_size    = ARRAY_SIZE(palmz71_keymap),
0072 };
0073 
0074 static struct omap_kp_platform_data palmz71_kp_data = {
0075     .rows   = 8,
0076     .cols   = 8,
0077     .keymap_data    = &palmz71_keymap_data,
0078     .rep    = true,
0079     .delay  = 80,
0080 };
0081 
0082 static struct resource palmz71_kp_resources[] = {
0083     [0] = {
0084         .start  = INT_KEYBOARD,
0085         .end    = INT_KEYBOARD,
0086         .flags  = IORESOURCE_IRQ,
0087     },
0088 };
0089 
0090 static struct platform_device palmz71_kp_device = {
0091     .name   = "omap-keypad",
0092     .id = -1,
0093     .dev    = {
0094         .platform_data = &palmz71_kp_data,
0095     },
0096     .num_resources  = ARRAY_SIZE(palmz71_kp_resources),
0097     .resource   = palmz71_kp_resources,
0098 };
0099 
0100 static struct mtd_partition palmz71_rom_partitions[] = {
0101     /* PalmOS "Small ROM", contains the bootloader and the debugger */
0102     {
0103         .name       = "smallrom",
0104         .offset     = 0,
0105         .size       = 0xa000,
0106         .mask_flags = MTD_WRITEABLE,
0107     },
0108     /* PalmOS "Big ROM", a filesystem with all the OS code and data */
0109     {
0110         .name   = "bigrom",
0111         .offset = SZ_128K,
0112         /*
0113          * 0x5f0000 bytes big in the multi-language ("EFIGS") version,
0114          * 0x7b0000 bytes in the English-only ("enUS") version.
0115          */
0116         .size       = 0x7b0000,
0117         .mask_flags = MTD_WRITEABLE,
0118     },
0119 };
0120 
0121 static struct physmap_flash_data palmz71_rom_data = {
0122     .width      = 2,
0123     .set_vpp    = omap1_set_vpp,
0124     .parts      = palmz71_rom_partitions,
0125     .nr_parts   = ARRAY_SIZE(palmz71_rom_partitions),
0126 };
0127 
0128 static struct resource palmz71_rom_resource = {
0129     .start  = OMAP_CS0_PHYS,
0130     .end    = OMAP_CS0_PHYS + SZ_8M - 1,
0131     .flags  = IORESOURCE_MEM,
0132 };
0133 
0134 static struct platform_device palmz71_rom_device = {
0135     .name   = "physmap-flash",
0136     .id = -1,
0137     .dev = {
0138         .platform_data = &palmz71_rom_data,
0139     },
0140     .num_resources  = 1,
0141     .resource   = &palmz71_rom_resource,
0142 };
0143 
0144 static struct platform_device palmz71_lcd_device = {
0145     .name   = "lcd_palmz71",
0146     .id = -1,
0147 };
0148 
0149 static struct platform_device palmz71_spi_device = {
0150     .name   = "spi_palmz71",
0151     .id = -1,
0152 };
0153 
0154 static struct omap_backlight_config palmz71_backlight_config = {
0155     .default_intensity  = 0xa0,
0156 };
0157 
0158 static struct platform_device palmz71_backlight_device = {
0159     .name   = "omap-bl",
0160     .id = -1,
0161     .dev    = {
0162         .platform_data = &palmz71_backlight_config,
0163     },
0164 };
0165 
0166 static struct platform_device *devices[] __initdata = {
0167     &palmz71_rom_device,
0168     &palmz71_kp_device,
0169     &palmz71_lcd_device,
0170     &palmz71_spi_device,
0171     &palmz71_backlight_device,
0172 };
0173 
0174 static int
0175 palmz71_get_pendown_state(void)
0176 {
0177     return !gpio_get_value(PALMZ71_PENIRQ_GPIO);
0178 }
0179 
0180 static const struct ads7846_platform_data palmz71_ts_info = {
0181     .model          = 7846,
0182     .vref_delay_usecs   = 100,  /* internal, no capacitor */
0183     .x_plate_ohms       = 419,
0184     .y_plate_ohms       = 486,
0185     .get_pendown_state  = palmz71_get_pendown_state,
0186 };
0187 
0188 static struct spi_board_info __initdata palmz71_boardinfo[] = { {
0189     /* MicroWire (bus 2) CS0 has an ads7846e */
0190     .modalias   = "ads7846",
0191     .platform_data  = &palmz71_ts_info,
0192     .max_speed_hz   = 120000    /* max sample rate at 3V */
0193                 * 26    /* command + data + overhead */,
0194     .bus_num    = 2,
0195     .chip_select    = 0,
0196 } };
0197 
0198 static struct omap_usb_config palmz71_usb_config __initdata = {
0199     .register_dev   = 1,    /* Mini-B only receptacle */
0200     .hmc_mode   = 0,
0201     .pins[0]    = 2,
0202 };
0203 
0204 static const struct omap_lcd_config palmz71_lcd_config __initconst = {
0205     .ctrl_name = "internal",
0206 };
0207 
0208 static irqreturn_t
0209 palmz71_powercable(int irq, void *dev_id)
0210 {
0211     if (gpio_get_value(PALMZ71_USBDETECT_GPIO)) {
0212         printk(KERN_INFO "PM: Power cable connected\n");
0213         irq_set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
0214                  IRQ_TYPE_EDGE_FALLING);
0215     } else {
0216         printk(KERN_INFO "PM: Power cable disconnected\n");
0217         irq_set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
0218                  IRQ_TYPE_EDGE_RISING);
0219     }
0220     return IRQ_HANDLED;
0221 }
0222 
0223 static void __init
0224 omap_mpu_wdt_mode(int mode)
0225 {
0226     if (mode)
0227         omap_writew(0x8000, OMAP_WDT_TIMER_MODE);
0228     else {
0229         omap_writew(0x00f5, OMAP_WDT_TIMER_MODE);
0230         omap_writew(0x00a0, OMAP_WDT_TIMER_MODE);
0231     }
0232 }
0233 
0234 static void __init
0235 palmz71_gpio_setup(int early)
0236 {
0237     if (early) {
0238         /* Only set GPIO1 so we have a working serial */
0239         gpio_direction_output(1, 1);
0240     } else {
0241         /* Set MMC/SD host WP pin as input */
0242         if (gpio_request(PALMZ71_MMC_WP_GPIO, "MMC WP") < 0) {
0243             printk(KERN_ERR "Could not reserve WP GPIO!\n");
0244             return;
0245         }
0246         gpio_direction_input(PALMZ71_MMC_WP_GPIO);
0247 
0248         /* Monitor the Power-cable-connected signal */
0249         if (gpio_request(PALMZ71_USBDETECT_GPIO, "USB detect") < 0) {
0250             printk(KERN_ERR
0251                 "Could not reserve cable signal GPIO!\n");
0252             return;
0253         }
0254         gpio_direction_input(PALMZ71_USBDETECT_GPIO);
0255         if (request_irq(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
0256                 palmz71_powercable, 0, "palmz71-cable", NULL))
0257             printk(KERN_ERR
0258                     "IRQ request for power cable failed!\n");
0259         palmz71_powercable(gpio_to_irq(PALMZ71_USBDETECT_GPIO), NULL);
0260     }
0261 }
0262 
0263 static void __init
0264 omap_palmz71_init(void)
0265 {
0266     /* mux pins for uarts */
0267     omap_cfg_reg(UART1_TX);
0268     omap_cfg_reg(UART1_RTS);
0269     omap_cfg_reg(UART2_TX);
0270     omap_cfg_reg(UART2_RTS);
0271     omap_cfg_reg(UART3_TX);
0272     omap_cfg_reg(UART3_RX);
0273 
0274     palmz71_gpio_setup(1);
0275     omap_mpu_wdt_mode(0);
0276 
0277     platform_add_devices(devices, ARRAY_SIZE(devices));
0278 
0279     palmz71_boardinfo[0].irq = gpio_to_irq(PALMZ71_PENIRQ_GPIO);
0280     spi_register_board_info(palmz71_boardinfo,
0281                 ARRAY_SIZE(palmz71_boardinfo));
0282     omap1_usb_init(&palmz71_usb_config);
0283     omap_serial_init();
0284     omap_register_i2c_bus(1, 100, NULL, 0);
0285     palmz71_gpio_setup(0);
0286 
0287     omapfb_set_lcd_config(&palmz71_lcd_config);
0288 }
0289 
0290 MACHINE_START(OMAP_PALMZ71, "OMAP310 based Palm Zire71")
0291     .atag_offset    = 0x100,
0292     .map_io     = omap15xx_map_io,
0293     .init_early     = omap1_init_early,
0294     .init_irq   = omap1_init_irq,
0295     .handle_irq = omap1_handle_irq,
0296     .init_machine   = omap_palmz71_init,
0297     .init_late  = omap1_init_late,
0298     .init_time  = omap1_timer_init,
0299     .restart    = omap1_restart,
0300 MACHINE_END