Path: blob/master/arch/arm/mach-omap1/board-ams-delta.c
26292 views
// SPDX-License-Identifier: GPL-2.0-only1/*2* linux/arch/arm/mach-omap1/board-ams-delta.c3*4* Modified from board-generic.c5*6* Board specific inits for the Amstrad E3 (codename Delta) videophone7*8* Copyright (C) 2006 Jonathan McDowell <[email protected]>9*/10#include <linux/gpio/driver.h>11#include <linux/gpio/machine.h>12#include <linux/gpio/consumer.h>13#include <linux/kernel.h>14#include <linux/init.h>15#include <linux/input.h>16#include <linux/interrupt.h>17#include <linux/leds.h>18#include <linux/mtd/nand-gpio.h>19#include <linux/mtd/partitions.h>20#include <linux/platform_device.h>21#include <linux/property.h>22#include <linux/regulator/consumer.h>23#include <linux/regulator/fixed.h>24#include <linux/regulator/machine.h>25#include <linux/serial_8250.h>26#include <linux/export.h>27#include <linux/omapfb.h>28#include <linux/io.h>29#include <linux/platform_data/gpio-omap.h>30#include <linux/soc/ti/omap1-mux.h>3132#include <asm/serial.h>33#include <asm/mach-types.h>34#include <asm/mach/arch.h>35#include <asm/mach/map.h>3637#include <linux/platform_data/keypad-omap.h>3839#include "hardware.h"40#include "usb.h"41#include "ams-delta-fiq.h"42#include "board-ams-delta.h"43#include "iomap.h"44#include "common.h"4546static const unsigned int ams_delta_keymap[] = {47KEY(0, 0, KEY_F1), /* Advert */4849KEY(0, 3, KEY_COFFEE), /* Games */50KEY(0, 2, KEY_QUESTION), /* Directory */51KEY(2, 3, KEY_CONNECT), /* Internet */52KEY(1, 2, KEY_SHOP), /* Services */53KEY(1, 1, KEY_PHONE), /* VoiceMail */5455KEY(0, 1, KEY_DELETE), /* Delete */56KEY(2, 2, KEY_PLAY), /* Play */57KEY(1, 0, KEY_PAGEUP), /* Up */58KEY(1, 3, KEY_PAGEDOWN), /* Down */59KEY(2, 0, KEY_EMAIL), /* ReadEmail */60KEY(2, 1, KEY_STOP), /* Stop */6162/* Numeric keypad portion */63KEY(0, 7, KEY_KP1),64KEY(0, 6, KEY_KP2),65KEY(0, 5, KEY_KP3),66KEY(1, 7, KEY_KP4),67KEY(1, 6, KEY_KP5),68KEY(1, 5, KEY_KP6),69KEY(2, 7, KEY_KP7),70KEY(2, 6, KEY_KP8),71KEY(2, 5, KEY_KP9),72KEY(3, 6, KEY_KP0),73KEY(3, 7, KEY_KPASTERISK),74KEY(3, 5, KEY_KPDOT), /* # key */75KEY(7, 2, KEY_NUMLOCK), /* Mute */76KEY(7, 1, KEY_KPMINUS), /* Recall */77KEY(6, 1, KEY_KPPLUS), /* Redial */78KEY(7, 6, KEY_KPSLASH), /* Handsfree */79KEY(6, 0, KEY_ENTER), /* Video */8081KEY(7, 4, KEY_CAMERA), /* Photo */8283KEY(0, 4, KEY_F2), /* Home */84KEY(1, 4, KEY_F3), /* Office */85KEY(2, 4, KEY_F4), /* Mobile */86KEY(7, 7, KEY_F5), /* SMS */87KEY(7, 5, KEY_F6), /* Email */8889/* QWERTY portion of keypad */90KEY(3, 4, KEY_Q),91KEY(3, 3, KEY_W),92KEY(3, 2, KEY_E),93KEY(3, 1, KEY_R),94KEY(3, 0, KEY_T),95KEY(4, 7, KEY_Y),96KEY(4, 6, KEY_U),97KEY(4, 5, KEY_I),98KEY(4, 4, KEY_O),99KEY(4, 3, KEY_P),100101KEY(4, 2, KEY_A),102KEY(4, 1, KEY_S),103KEY(4, 0, KEY_D),104KEY(5, 7, KEY_F),105KEY(5, 6, KEY_G),106KEY(5, 5, KEY_H),107KEY(5, 4, KEY_J),108KEY(5, 3, KEY_K),109KEY(5, 2, KEY_L),110111KEY(5, 1, KEY_Z),112KEY(5, 0, KEY_X),113KEY(6, 7, KEY_C),114KEY(6, 6, KEY_V),115KEY(6, 5, KEY_B),116KEY(6, 4, KEY_N),117KEY(6, 3, KEY_M),118KEY(6, 2, KEY_SPACE),119120KEY(7, 0, KEY_LEFTSHIFT), /* Vol up */121KEY(7, 3, KEY_LEFTCTRL), /* Vol down */122};123124#define LATCH1_PHYS 0x01000000125#define LATCH1_VIRT 0xEA000000126#define MODEM_PHYS 0x04000000127#define MODEM_VIRT 0xEB000000128#define LATCH2_PHYS 0x08000000129#define LATCH2_VIRT 0xEC000000130131static struct map_desc ams_delta_io_desc[] __initdata = {132/* AMS_DELTA_LATCH1 */133{134.virtual = LATCH1_VIRT,135.pfn = __phys_to_pfn(LATCH1_PHYS),136.length = 0x01000000,137.type = MT_DEVICE138},139/* AMS_DELTA_LATCH2 */140{141.virtual = LATCH2_VIRT,142.pfn = __phys_to_pfn(LATCH2_PHYS),143.length = 0x01000000,144.type = MT_DEVICE145},146/* AMS_DELTA_MODEM */147{148.virtual = MODEM_VIRT,149.pfn = __phys_to_pfn(MODEM_PHYS),150.length = 0x01000000,151.type = MT_DEVICE152}153};154155static const struct omap_lcd_config ams_delta_lcd_config __initconst = {156.ctrl_name = "internal",157};158159static struct omap_usb_config ams_delta_usb_config __initdata = {160.register_host = 1,161.hmc_mode = 16,162.pins[0] = 2,163};164165#define LATCH1_NGPIO 8166167static struct resource latch1_resources[] = {168[0] = {169.name = "dat",170.start = LATCH1_PHYS,171.end = LATCH1_PHYS + (LATCH1_NGPIO - 1) / 8,172.flags = IORESOURCE_MEM,173},174};175176#define LATCH1_LABEL "latch1"177178static const struct property_entry latch1_gpio_props[] = {179PROPERTY_ENTRY_STRING("label", LATCH1_LABEL),180PROPERTY_ENTRY_U32("ngpios", LATCH1_NGPIO),181{ }182};183184static const struct platform_device_info latch1_gpio_devinfo = {185.name = "basic-mmio-gpio",186.id = 0,187.res = latch1_resources,188.num_res = ARRAY_SIZE(latch1_resources),189.properties = latch1_gpio_props,190};191192#define LATCH1_PIN_LED_CAMERA 0193#define LATCH1_PIN_LED_ADVERT 1194#define LATCH1_PIN_LED_MAIL 2195#define LATCH1_PIN_LED_HANDSFREE 3196#define LATCH1_PIN_LED_VOICEMAIL 4197#define LATCH1_PIN_LED_VOICE 5198#define LATCH1_PIN_DOCKIT1 6199#define LATCH1_PIN_DOCKIT2 7200201#define LATCH2_NGPIO 16202203static struct resource latch2_resources[] = {204[0] = {205.name = "dat",206.start = LATCH2_PHYS,207.end = LATCH2_PHYS + (LATCH2_NGPIO - 1) / 8,208.flags = IORESOURCE_MEM,209},210};211212#define LATCH2_LABEL "latch2"213214static const struct property_entry latch2_gpio_props[] = {215PROPERTY_ENTRY_STRING("label", LATCH2_LABEL),216PROPERTY_ENTRY_U32("ngpios", LATCH2_NGPIO),217{ }218};219220static struct platform_device_info latch2_gpio_devinfo = {221.name = "basic-mmio-gpio",222.id = 1,223.res = latch2_resources,224.num_res = ARRAY_SIZE(latch2_resources),225.properties = latch2_gpio_props,226};227228#define LATCH2_PIN_LCD_VBLEN 0229#define LATCH2_PIN_LCD_NDISP 1230#define LATCH2_PIN_NAND_NCE 2231#define LATCH2_PIN_NAND_NRE 3232#define LATCH2_PIN_NAND_NWP 4233#define LATCH2_PIN_NAND_NWE 5234#define LATCH2_PIN_NAND_ALE 6235#define LATCH2_PIN_NAND_CLE 7236#define LATCH2_PIN_KEYBRD_PWR 8237#define LATCH2_PIN_KEYBRD_DATAOUT 9238#define LATCH2_PIN_SCARD_RSTIN 10239#define LATCH2_PIN_SCARD_CMDVCC 11240#define LATCH2_PIN_MODEM_NRESET 12241#define LATCH2_PIN_MODEM_CODEC 13242#define LATCH2_PIN_HANDSFREE_MUTE 14243#define LATCH2_PIN_HANDSET_MUTE 15244245static struct regulator_consumer_supply modem_nreset_consumers[] = {246REGULATOR_SUPPLY("RESET#", "serial8250.1"),247REGULATOR_SUPPLY("POR", "cx20442-codec"),248};249250static struct regulator_init_data modem_nreset_data = {251.constraints = {252.valid_ops_mask = REGULATOR_CHANGE_STATUS,253.boot_on = 1,254},255.num_consumer_supplies = ARRAY_SIZE(modem_nreset_consumers),256.consumer_supplies = modem_nreset_consumers,257};258259static struct fixed_voltage_config modem_nreset_config = {260.supply_name = "modem_nreset",261.microvolts = 3300000,262.startup_delay = 25000,263.enabled_at_boot = 1,264.init_data = &modem_nreset_data,265};266267static struct platform_device modem_nreset_device = {268.name = "reg-fixed-voltage",269.id = -1,270.dev = {271.platform_data = &modem_nreset_config,272},273};274275static struct gpiod_lookup_table ams_delta_nreset_gpiod_table = {276.dev_id = "reg-fixed-voltage",277.table = {278GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_MODEM_NRESET,279NULL, GPIO_ACTIVE_HIGH),280{ },281},282};283284struct modem_private_data {285struct regulator *regulator;286};287288static struct modem_private_data modem_priv;289290/*291* Define partitions for flash device292*/293294static struct mtd_partition partition_info[] = {295{ .name = "Kernel",296.offset = 0,297.size = 3 * SZ_1M + SZ_512K },298{ .name = "u-boot",299.offset = 3 * SZ_1M + SZ_512K,300.size = SZ_256K },301{ .name = "u-boot params",302.offset = 3 * SZ_1M + SZ_512K + SZ_256K,303.size = SZ_256K },304{ .name = "Amstrad LDR",305.offset = 4 * SZ_1M,306.size = SZ_256K },307{ .name = "File system",308.offset = 4 * SZ_1M + 1 * SZ_256K,309.size = 27 * SZ_1M },310{ .name = "PBL reserved",311.offset = 32 * SZ_1M - 3 * SZ_256K,312.size = 3 * SZ_256K },313};314315static struct gpio_nand_platdata nand_platdata = {316.parts = partition_info,317.num_parts = ARRAY_SIZE(partition_info),318};319320static struct platform_device ams_delta_nand_device = {321.name = "ams-delta-nand",322.id = -1,323.dev = {324.platform_data = &nand_platdata,325},326};327328#define OMAP_GPIO_LABEL "gpio-0-15"329#define OMAP_MPUIO_LABEL "mpuio"330331static struct gpiod_lookup_table ams_delta_nand_gpio_table = {332.table = {333GPIO_LOOKUP(OMAP_GPIO_LABEL, AMS_DELTA_GPIO_PIN_NAND_RB, "rdy",3340),335GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NCE, "nce",336GPIO_ACTIVE_LOW),337GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NRE, "nre",338GPIO_ACTIVE_LOW),339GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NWP, "nwp",340GPIO_ACTIVE_LOW),341GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NWE, "nwe",342GPIO_ACTIVE_LOW),343GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_ALE, "ale", 0),344GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_CLE, "cle", 0),345GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 0, "data", 0, 0),346GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 1, "data", 1, 0),347GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 2, "data", 2, 0),348GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 3, "data", 3, 0),349GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 4, "data", 4, 0),350GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 5, "data", 5, 0),351GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 6, "data", 6, 0),352GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 7, "data", 7, 0),353{ },354},355};356357static struct resource ams_delta_kp_resources[] = {358[0] = {359.start = INT_KEYBOARD,360.end = INT_KEYBOARD,361.flags = IORESOURCE_IRQ,362},363};364365static const struct matrix_keymap_data ams_delta_keymap_data = {366.keymap = ams_delta_keymap,367.keymap_size = ARRAY_SIZE(ams_delta_keymap),368};369370static struct omap_kp_platform_data ams_delta_kp_data = {371.rows = 8,372.cols = 8,373.keymap_data = &ams_delta_keymap_data,374.delay = 9,375};376377static struct platform_device ams_delta_kp_device = {378.name = "omap-keypad",379.id = -1,380.dev = {381.platform_data = &ams_delta_kp_data,382},383.num_resources = ARRAY_SIZE(ams_delta_kp_resources),384.resource = ams_delta_kp_resources,385};386387static struct platform_device ams_delta_lcd_device = {388.name = "lcd_ams_delta",389.id = -1,390};391392static struct gpiod_lookup_table ams_delta_lcd_gpio_table = {393.table = {394GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_LCD_VBLEN, "vblen", 0),395GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_LCD_NDISP, "ndisp", 0),396{ },397},398};399400static struct gpio_led gpio_leds[] __initdata = {401[LATCH1_PIN_LED_CAMERA] = {402.name = "camera",403.default_state = LEDS_GPIO_DEFSTATE_OFF,404},405[LATCH1_PIN_LED_ADVERT] = {406.name = "advert",407.default_state = LEDS_GPIO_DEFSTATE_OFF,408},409[LATCH1_PIN_LED_MAIL] = {410.name = "email",411.default_state = LEDS_GPIO_DEFSTATE_OFF,412},413[LATCH1_PIN_LED_HANDSFREE] = {414.name = "handsfree",415.default_state = LEDS_GPIO_DEFSTATE_OFF,416},417[LATCH1_PIN_LED_VOICEMAIL] = {418.name = "voicemail",419.default_state = LEDS_GPIO_DEFSTATE_OFF,420},421[LATCH1_PIN_LED_VOICE] = {422.name = "voice",423.default_state = LEDS_GPIO_DEFSTATE_OFF,424},425};426427static const struct gpio_led_platform_data leds_pdata __initconst = {428.leds = gpio_leds,429.num_leds = ARRAY_SIZE(gpio_leds),430};431432static struct gpiod_lookup_table leds_gpio_table = {433.table = {434GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_CAMERA, NULL,435LATCH1_PIN_LED_CAMERA, 0),436GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_ADVERT, NULL,437LATCH1_PIN_LED_ADVERT, 0),438GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_MAIL, NULL,439LATCH1_PIN_LED_MAIL, 0),440GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_HANDSFREE, NULL,441LATCH1_PIN_LED_HANDSFREE, 0),442GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_VOICEMAIL, NULL,443LATCH1_PIN_LED_VOICEMAIL, 0),444GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_VOICE, NULL,445LATCH1_PIN_LED_VOICE, 0),446{ },447},448};449450static struct platform_device ams_delta_audio_device = {451.name = "ams-delta-audio",452.id = -1,453};454455static struct gpiod_lookup_table ams_delta_audio_gpio_table = {456.table = {457GPIO_LOOKUP(OMAP_GPIO_LABEL, AMS_DELTA_GPIO_PIN_HOOK_SWITCH,458"hook_switch", 0),459GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_MODEM_CODEC,460"modem_codec", 0),461GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_HANDSFREE_MUTE,462"handsfree_mute", 0),463GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_HANDSET_MUTE,464"handset_mute", 0),465{ },466},467};468469static struct platform_device cx20442_codec_device = {470.name = "cx20442-codec",471.id = -1,472};473474static struct resource ams_delta_serio_resources[] = {475{476.flags = IORESOURCE_IRQ,477/*478* Initialize IRQ resource with invalid IRQ number.479* It will be replaced with dynamically allocated GPIO IRQ480* obtained from GPIO chip as soon as the chip is available.481*/482.start = -EINVAL,483.end = -EINVAL,484},485};486487static struct platform_device ams_delta_serio_device = {488.name = "ams-delta-serio",489.id = PLATFORM_DEVID_NONE,490.dev = {491/*492* Initialize .platform_data explicitly with NULL to493* indicate it is going to be used. It will be replaced494* with FIQ buffer address as soon as FIQ is initialized.495*/496.platform_data = NULL,497},498.num_resources = ARRAY_SIZE(ams_delta_serio_resources),499.resource = ams_delta_serio_resources,500};501502static struct regulator_consumer_supply keybrd_pwr_consumers[] = {503/*504* Initialize supply .dev_name with NULL. It will be replaced505* with serio dev_name() as soon as the serio device is registered.506*/507REGULATOR_SUPPLY("vcc", NULL),508};509510static struct regulator_init_data keybrd_pwr_initdata = {511.constraints = {512.valid_ops_mask = REGULATOR_CHANGE_STATUS,513},514.num_consumer_supplies = ARRAY_SIZE(keybrd_pwr_consumers),515.consumer_supplies = keybrd_pwr_consumers,516};517518static struct fixed_voltage_config keybrd_pwr_config = {519.supply_name = "keybrd_pwr",520.microvolts = 5000000,521.init_data = &keybrd_pwr_initdata,522};523524static struct platform_device keybrd_pwr_device = {525.name = "reg-fixed-voltage",526.id = PLATFORM_DEVID_AUTO,527.dev = {528.platform_data = &keybrd_pwr_config,529},530};531532static struct gpiod_lookup_table keybrd_pwr_gpio_table = {533.table = {534GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_KEYBRD_PWR, NULL,535GPIO_ACTIVE_HIGH),536{ },537},538};539540static struct platform_device *ams_delta_devices[] __initdata = {541&ams_delta_kp_device,542&ams_delta_audio_device,543&ams_delta_serio_device,544&ams_delta_nand_device,545&ams_delta_lcd_device,546&cx20442_codec_device,547&modem_nreset_device,548};549550static struct gpiod_lookup_table *ams_delta_gpio_tables[] __initdata = {551&ams_delta_nreset_gpiod_table,552&ams_delta_audio_gpio_table,553&keybrd_pwr_gpio_table,554&ams_delta_lcd_gpio_table,555&ams_delta_nand_gpio_table,556};557558static struct gpiod_hog ams_delta_gpio_hogs[] = {559GPIO_HOG(LATCH2_LABEL, LATCH2_PIN_KEYBRD_DATAOUT, "keybrd_dataout",560GPIO_ACTIVE_HIGH, GPIOD_OUT_LOW),561{},562};563564static struct plat_serial8250_port ams_delta_modem_ports[];565566/*567* Obtain MODEM IRQ GPIO descriptor using its hardware pin568* number and assign related IRQ number to the MODEM port.569* Keep the GPIO descriptor open so nobody steps in.570*/571static void __init modem_assign_irq(struct gpio_chip *chip)572{573struct gpio_desc *gpiod;574575gpiod = gpiochip_request_own_desc(chip, AMS_DELTA_GPIO_PIN_MODEM_IRQ,576"modem_irq", GPIO_ACTIVE_HIGH,577GPIOD_IN);578if (IS_ERR(gpiod)) {579pr_err("%s: modem IRQ GPIO request failed (%ld)\n", __func__,580PTR_ERR(gpiod));581} else {582ams_delta_modem_ports[0].irq = gpiod_to_irq(gpiod);583}584}585586/*587* The purpose of this function is to take care of proper initialization of588* devices and data structures which depend on GPIO lines provided by OMAP GPIO589* banks but their drivers don't use GPIO lookup tables or GPIO layer at all.590* The function may be called as soon as OMAP GPIO devices are probed.591* Since that happens at postcore_initcall, it can be called successfully592* from init_machine or later.593* Dependent devices may be registered from within this function or later.594*/595static void __init omap_gpio_deps_init(void)596{597struct gpio_device *gdev;598struct gpio_chip *chip;599600/*601* Some drivers may not use GPIO lookup tables but need to be provided602* with GPIO numbers. The same applies to GPIO based IRQ lines - some603* drivers may even not use GPIO layer but expect just IRQ numbers.604* We could either define GPIO lookup tables then use them on behalf605* of those devices, or we can use GPIO driver level methods for606* identification of GPIO and IRQ numbers.607*608* This reference will be leaked but that's alright as this device609* never goes down.610*/611gdev = gpio_device_find_by_label(OMAP_GPIO_LABEL);612if (!gdev) {613pr_err("%s: OMAP GPIO device not found\n", __func__);614return;615}616617chip = gpio_device_get_chip(gdev);618619/*620* Start with FIQ initialization as it may have to request621* and release successfully each OMAP GPIO pin in turn.622*/623ams_delta_init_fiq(chip, &ams_delta_serio_device);624625modem_assign_irq(chip);626}627628/*629* Initialize latch2 pins with values which are safe for dependent on-board630* devices or useful for their successull initialization even before GPIO631* driver takes control over the latch pins:632* - LATCH2_PIN_LCD_VBLEN = 0633* - LATCH2_PIN_LCD_NDISP = 0 Keep LCD device powered off before its634* driver takes control over it.635* - LATCH2_PIN_NAND_NCE = 0636* - LATCH2_PIN_NAND_NWP = 0 Keep NAND device down and write-637* protected before its driver takes638* control over it.639* - LATCH2_PIN_KEYBRD_PWR = 0 Keep keyboard powered off before serio640* driver takes control over it.641* - LATCH2_PIN_KEYBRD_DATAOUT = 0 Keep low to avoid corruption of first642* byte of data received from attached643* keyboard when serio device is probed;644* the pin is also hogged low by the latch2645* GPIO driver as soon as it is ready.646* - LATCH2_PIN_MODEM_NRESET = 1 Enable voice MODEM device, allowing for647* its successful probe even before a648* regulator it depends on, which in turn649* takes control over the pin, is set up.650* - LATCH2_PIN_MODEM_CODEC = 1 Attach voice MODEM CODEC data port651* to the MODEM so the CODEC is under652* control even if audio driver doesn't653* take it over.654*/655static void __init ams_delta_latch2_init(void)656{657u16 latch2 = 1 << LATCH2_PIN_MODEM_NRESET | 1 << LATCH2_PIN_MODEM_CODEC;658659__raw_writew(latch2, IOMEM(LATCH2_VIRT));660}661662static void __init ams_delta_init(void)663{664struct platform_device *leds_pdev;665666/* mux pins for uarts */667omap_cfg_reg(UART1_TX);668omap_cfg_reg(UART1_RTS);669670/* parallel camera interface */671omap_cfg_reg(H19_1610_CAM_EXCLK);672omap_cfg_reg(J15_1610_CAM_LCLK);673omap_cfg_reg(L18_1610_CAM_VS);674omap_cfg_reg(L15_1610_CAM_HS);675omap_cfg_reg(L19_1610_CAM_D0);676omap_cfg_reg(K14_1610_CAM_D1);677omap_cfg_reg(K15_1610_CAM_D2);678omap_cfg_reg(K19_1610_CAM_D3);679omap_cfg_reg(K18_1610_CAM_D4);680omap_cfg_reg(J14_1610_CAM_D5);681omap_cfg_reg(J19_1610_CAM_D6);682omap_cfg_reg(J18_1610_CAM_D7);683684omap_gpio_deps_init();685ams_delta_latch2_init();686gpiod_add_hogs(ams_delta_gpio_hogs);687688omap_serial_init();689omap_register_i2c_bus(1, 100, NULL, 0);690691omap1_usb_init(&ams_delta_usb_config);692platform_add_devices(ams_delta_devices, ARRAY_SIZE(ams_delta_devices));693694platform_device_register_full(&latch1_gpio_devinfo);695platform_device_register_full(&latch2_gpio_devinfo);696697/*698* As soon as regulator consumers have been registered, assign their699* dev_names to consumer supply entries of respective regulators.700*/701keybrd_pwr_consumers[0].dev_name =702dev_name(&ams_delta_serio_device.dev);703704/*705* Once consumer supply entries are populated with dev_names,706* register regulator devices. At this stage only the keyboard707* power regulator has its consumer supply table fully populated.708*/709platform_device_register(&keybrd_pwr_device);710711/*712* As soon as GPIO consumers have been registered, assign713* their dev_names to respective GPIO lookup tables.714*/715ams_delta_audio_gpio_table.dev_id =716dev_name(&ams_delta_audio_device.dev);717keybrd_pwr_gpio_table.dev_id = dev_name(&keybrd_pwr_device.dev);718ams_delta_nand_gpio_table.dev_id = dev_name(&ams_delta_nand_device.dev);719ams_delta_lcd_gpio_table.dev_id = dev_name(&ams_delta_lcd_device.dev);720721/*722* Once GPIO lookup tables are populated with dev_names, register them.723*/724gpiod_add_lookup_tables(ams_delta_gpio_tables,725ARRAY_SIZE(ams_delta_gpio_tables));726727leds_pdev = gpio_led_register_device(PLATFORM_DEVID_NONE, &leds_pdata);728if (!IS_ERR_OR_NULL(leds_pdev)) {729leds_gpio_table.dev_id = dev_name(&leds_pdev->dev);730gpiod_add_lookup_table(&leds_gpio_table);731}732733omap_writew(omap_readw(ARM_RSTCT1) | 0x0004, ARM_RSTCT1);734735omapfb_set_lcd_config(&ams_delta_lcd_config);736}737738static void modem_pm(struct uart_port *port, unsigned int state, unsigned old)739{740struct modem_private_data *priv = port->private_data;741int ret;742743if (!priv)744return;745746if (IS_ERR(priv->regulator))747return;748749if (state == old)750return;751752if (state == 0)753ret = regulator_enable(priv->regulator);754else if (old == 0)755ret = regulator_disable(priv->regulator);756else757ret = 0;758759if (ret)760dev_warn(port->dev,761"ams_delta modem_pm: failed to %sable regulator: %d\n",762state ? "dis" : "en", ret);763}764765static struct plat_serial8250_port ams_delta_modem_ports[] = {766{767.membase = IOMEM(MODEM_VIRT),768.mapbase = MODEM_PHYS,769.irq = IRQ_NOTCONNECTED, /* changed later */770.flags = UPF_BOOT_AUTOCONF,771.irqflags = IRQF_TRIGGER_RISING,772.iotype = UPIO_MEM,773.regshift = 1,774.uartclk = BASE_BAUD * 16,775.pm = modem_pm,776.private_data = &modem_priv,777},778{ },779};780781static int ams_delta_modem_pm_activate(struct device *dev)782{783modem_priv.regulator = regulator_get(dev, "RESET#");784if (IS_ERR(modem_priv.regulator))785return -EPROBE_DEFER;786787return 0;788}789790static struct dev_pm_domain ams_delta_modem_pm_domain = {791.activate = ams_delta_modem_pm_activate,792};793794static struct platform_device ams_delta_modem_device = {795.name = "serial8250",796.id = PLAT8250_DEV_PLATFORM1,797.dev = {798.platform_data = ams_delta_modem_ports,799.pm_domain = &ams_delta_modem_pm_domain,800},801};802803/*804* This function expects MODEM IRQ number already assigned to the port.805* The MODEM device requires its RESET# pin kept high during probe.806* That requirement can be fulfilled in several ways:807* - with a descriptor of already functional modem_nreset regulator808* assigned to the MODEM private data,809* - with the regulator not yet controlled by modem_pm function but810* already enabled by default on probe,811* - before the modem_nreset regulator is probed, with the pin already812* set high explicitly.813* The last one is already guaranteed by ams_delta_latch2_init() called814* from machine_init.815* In order to avoid taking over ttyS0 device slot, the MODEM device816* should be registered after OMAP serial ports. Since those ports817* are registered at arch_initcall, this function can be called safely818* at arch_initcall_sync earliest.819*/820static int __init ams_delta_modem_init(void)821{822if (!machine_is_ams_delta())823return -ENODEV;824825omap_cfg_reg(M14_1510_GPIO2);826827/* Initialize the modem_nreset regulator consumer before use */828modem_priv.regulator = ERR_PTR(-ENODEV);829830return platform_device_register(&ams_delta_modem_device);831}832arch_initcall_sync(ams_delta_modem_init);833834static void __init ams_delta_map_io(void)835{836omap1_map_io();837iotable_init(ams_delta_io_desc, ARRAY_SIZE(ams_delta_io_desc));838}839840MACHINE_START(AMS_DELTA, "Amstrad E3 (Delta)")841/* Maintainer: Jonathan McDowell <[email protected]> */842.atag_offset = 0x100,843.map_io = ams_delta_map_io,844.init_early = omap1_init_early,845.init_irq = omap1_init_irq,846.init_machine = ams_delta_init,847.init_late = omap1_init_late,848.init_time = omap1_timer_init,849.restart = omap1_restart,850MACHINE_END851852853