Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * linux/arch/arm/mach-omap1/board-ams-delta.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Modified from board-generic.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Board specific inits for the Amstrad E3 (codename Delta) videophone
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * Copyright (C) 2006 Jonathan McDowell <noodles@earth.li>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/gpio/driver.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/gpio/machine.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/gpio/consumer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/leds.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/mtd/nand-gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/mtd/partitions.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <linux/regulator/consumer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include <linux/regulator/fixed.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include <linux/regulator/machine.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include <linux/serial_8250.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #include <linux/omapfb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #include <linux/platform_data/gpio-omap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #include <asm/serial.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #include <asm/mach-types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #include <asm/mach/arch.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #include <asm/mach/map.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #include <linux/platform_data/keypad-omap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #include <mach/mux.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #include <mach/hardware.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #include <mach/usb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #include "ams-delta-fiq.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #include "board-ams-delta.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #include "iomap.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #include "common.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) static const unsigned int ams_delta_keymap[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	KEY(0, 0, KEY_F1),		/* Advert    */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	KEY(0, 3, KEY_COFFEE),		/* Games     */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	KEY(0, 2, KEY_QUESTION),	/* Directory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	KEY(2, 3, KEY_CONNECT),		/* Internet  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	KEY(1, 2, KEY_SHOP),		/* Services  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	KEY(1, 1, KEY_PHONE),		/* VoiceMail */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	KEY(0, 1, KEY_DELETE),		/* Delete    */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	KEY(2, 2, KEY_PLAY),		/* Play      */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	KEY(1, 0, KEY_PAGEUP),		/* Up        */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	KEY(1, 3, KEY_PAGEDOWN),	/* Down      */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	KEY(2, 0, KEY_EMAIL),		/* ReadEmail */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	KEY(2, 1, KEY_STOP),		/* Stop      */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	/* Numeric keypad portion */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	KEY(0, 7, KEY_KP1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	KEY(0, 6, KEY_KP2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	KEY(0, 5, KEY_KP3),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	KEY(1, 7, KEY_KP4),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	KEY(1, 6, KEY_KP5),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	KEY(1, 5, KEY_KP6),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	KEY(2, 7, KEY_KP7),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	KEY(2, 6, KEY_KP8),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	KEY(2, 5, KEY_KP9),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	KEY(3, 6, KEY_KP0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	KEY(3, 7, KEY_KPASTERISK),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	KEY(3, 5, KEY_KPDOT),		/* # key     */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	KEY(7, 2, KEY_NUMLOCK),		/* Mute      */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	KEY(7, 1, KEY_KPMINUS),		/* Recall    */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	KEY(6, 1, KEY_KPPLUS),		/* Redial    */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	KEY(7, 6, KEY_KPSLASH),		/* Handsfree */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	KEY(6, 0, KEY_ENTER),		/* Video     */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	KEY(7, 4, KEY_CAMERA),		/* Photo     */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	KEY(0, 4, KEY_F2),		/* Home      */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	KEY(1, 4, KEY_F3),		/* Office    */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	KEY(2, 4, KEY_F4),		/* Mobile    */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	KEY(7, 7, KEY_F5),		/* SMS       */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	KEY(7, 5, KEY_F6),		/* Email     */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	/* QWERTY portion of keypad */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	KEY(3, 4, KEY_Q),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	KEY(3, 3, KEY_W),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	KEY(3, 2, KEY_E),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	KEY(3, 1, KEY_R),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	KEY(3, 0, KEY_T),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	KEY(4, 7, KEY_Y),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	KEY(4, 6, KEY_U),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	KEY(4, 5, KEY_I),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	KEY(4, 4, KEY_O),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	KEY(4, 3, KEY_P),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	KEY(4, 2, KEY_A),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	KEY(4, 1, KEY_S),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	KEY(4, 0, KEY_D),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	KEY(5, 7, KEY_F),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	KEY(5, 6, KEY_G),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	KEY(5, 5, KEY_H),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	KEY(5, 4, KEY_J),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	KEY(5, 3, KEY_K),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	KEY(5, 2, KEY_L),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	KEY(5, 1, KEY_Z),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	KEY(5, 0, KEY_X),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	KEY(6, 7, KEY_C),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	KEY(6, 6, KEY_V),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	KEY(6, 5, KEY_B),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	KEY(6, 4, KEY_N),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	KEY(6, 3, KEY_M),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	KEY(6, 2, KEY_SPACE),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	KEY(7, 0, KEY_LEFTSHIFT),	/* Vol up    */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	KEY(7, 3, KEY_LEFTCTRL),	/* Vol down  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) #define LATCH1_PHYS	0x01000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) #define LATCH1_VIRT	0xEA000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) #define MODEM_PHYS	0x04000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) #define MODEM_VIRT	0xEB000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) #define LATCH2_PHYS	0x08000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) #define LATCH2_VIRT	0xEC000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) static struct map_desc ams_delta_io_desc[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	/* AMS_DELTA_LATCH1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		.virtual	= LATCH1_VIRT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		.pfn		= __phys_to_pfn(LATCH1_PHYS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		.length		= 0x01000000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		.type		= MT_DEVICE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	/* AMS_DELTA_LATCH2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		.virtual	= LATCH2_VIRT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 		.pfn		= __phys_to_pfn(LATCH2_PHYS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		.length		= 0x01000000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		.type		= MT_DEVICE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	/* AMS_DELTA_MODEM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 		.virtual	= MODEM_VIRT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 		.pfn		= __phys_to_pfn(MODEM_PHYS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 		.length		= 0x01000000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 		.type		= MT_DEVICE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) static const struct omap_lcd_config ams_delta_lcd_config __initconst = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	.ctrl_name	= "internal",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) static struct omap_usb_config ams_delta_usb_config __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	.register_host	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	.hmc_mode	= 16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	.pins[0]	= 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) #define LATCH1_NGPIO		8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) static struct resource latch1_resources[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	[0] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		.name	= "dat",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		.start	= LATCH1_PHYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		.end	= LATCH1_PHYS + (LATCH1_NGPIO - 1) / 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		.flags	= IORESOURCE_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) #define LATCH1_LABEL	"latch1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) static struct bgpio_pdata latch1_pdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	.label	= LATCH1_LABEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	.base	= -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	.ngpio	= LATCH1_NGPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) static struct platform_device latch1_gpio_device = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	.name		= "basic-mmio-gpio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	.id		= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	.resource	= latch1_resources,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	.num_resources	= ARRAY_SIZE(latch1_resources),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	.dev		= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		.platform_data	= &latch1_pdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) #define LATCH1_PIN_LED_CAMERA		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) #define LATCH1_PIN_LED_ADVERT		1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) #define LATCH1_PIN_LED_MAIL		2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) #define LATCH1_PIN_LED_HANDSFREE	3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) #define LATCH1_PIN_LED_VOICEMAIL	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) #define LATCH1_PIN_LED_VOICE		5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) #define LATCH1_PIN_DOCKIT1		6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) #define LATCH1_PIN_DOCKIT2		7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) #define LATCH2_NGPIO			16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) static struct resource latch2_resources[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	[0] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		.name	= "dat",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 		.start	= LATCH2_PHYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		.end	= LATCH2_PHYS + (LATCH2_NGPIO - 1) / 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		.flags	= IORESOURCE_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) #define LATCH2_LABEL	"latch2"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) static struct bgpio_pdata latch2_pdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	.label	= LATCH2_LABEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	.base	= -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	.ngpio	= LATCH2_NGPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) static struct platform_device latch2_gpio_device = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	.name		= "basic-mmio-gpio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	.id		= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	.resource	= latch2_resources,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	.num_resources	= ARRAY_SIZE(latch2_resources),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	.dev		= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		.platform_data	= &latch2_pdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) #define LATCH2_PIN_LCD_VBLEN		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) #define LATCH2_PIN_LCD_NDISP		1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) #define LATCH2_PIN_NAND_NCE		2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) #define LATCH2_PIN_NAND_NRE		3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) #define LATCH2_PIN_NAND_NWP		4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) #define LATCH2_PIN_NAND_NWE		5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) #define LATCH2_PIN_NAND_ALE		6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) #define LATCH2_PIN_NAND_CLE		7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) #define LATCH2_PIN_KEYBRD_PWR		8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) #define LATCH2_PIN_KEYBRD_DATAOUT	9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) #define LATCH2_PIN_SCARD_RSTIN		10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) #define LATCH2_PIN_SCARD_CMDVCC		11
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) #define LATCH2_PIN_MODEM_NRESET		12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) #define LATCH2_PIN_MODEM_CODEC		13
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) #define LATCH2_PIN_HANDSFREE_MUTE	14
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) #define LATCH2_PIN_HANDSET_MUTE		15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) static struct regulator_consumer_supply modem_nreset_consumers[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	REGULATOR_SUPPLY("RESET#", "serial8250.1"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	REGULATOR_SUPPLY("POR", "cx20442-codec"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) static struct regulator_init_data modem_nreset_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	.constraints		= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 		.valid_ops_mask		= REGULATOR_CHANGE_STATUS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 		.boot_on		= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	.num_consumer_supplies	= ARRAY_SIZE(modem_nreset_consumers),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	.consumer_supplies	= modem_nreset_consumers,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) static struct fixed_voltage_config modem_nreset_config = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	.supply_name		= "modem_nreset",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	.microvolts		= 3300000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	.startup_delay		= 25000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	.enabled_at_boot	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	.init_data		= &modem_nreset_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) static struct platform_device modem_nreset_device = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	.name	= "reg-fixed-voltage",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	.id	= -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	.dev	= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 		.platform_data	= &modem_nreset_config,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) static struct gpiod_lookup_table ams_delta_nreset_gpiod_table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	.dev_id = "reg-fixed-voltage",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	.table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 		GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_MODEM_NRESET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 			    NULL, GPIO_ACTIVE_HIGH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 		{ },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) struct modem_private_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	struct regulator *regulator;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) static struct modem_private_data modem_priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)  * Define partitions for flash device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) static struct mtd_partition partition_info[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	{ .name		= "Kernel",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	  .offset	= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	  .size		= 3 * SZ_1M + SZ_512K },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	{ .name		= "u-boot",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	  .offset	= 3 * SZ_1M + SZ_512K,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	  .size		= SZ_256K },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	{ .name		= "u-boot params",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	  .offset	= 3 * SZ_1M + SZ_512K + SZ_256K,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	  .size		= SZ_256K },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	{ .name		= "Amstrad LDR",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	  .offset	= 4 * SZ_1M,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	  .size		= SZ_256K },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 	{ .name		= "File system",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	  .offset	= 4 * SZ_1M + 1 * SZ_256K,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	  .size		= 27 * SZ_1M },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	{ .name		= "PBL reserved",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	  .offset	= 32 * SZ_1M - 3 * SZ_256K,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	  .size		=  3 * SZ_256K },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) static struct gpio_nand_platdata nand_platdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	.parts		= partition_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 	.num_parts	= ARRAY_SIZE(partition_info),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) static struct platform_device ams_delta_nand_device = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	.name	= "ams-delta-nand",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	.id	= -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	.dev	= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 		.platform_data = &nand_platdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) #define OMAP_GPIO_LABEL		"gpio-0-15"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) #define OMAP_MPUIO_LABEL	"mpuio"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) static struct gpiod_lookup_table ams_delta_nand_gpio_table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	.table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 		GPIO_LOOKUP(OMAP_GPIO_LABEL, AMS_DELTA_GPIO_PIN_NAND_RB, "rdy",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 			    0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 		GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NCE, "nce",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 			    GPIO_ACTIVE_LOW),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 		GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NRE, "nre",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 			    GPIO_ACTIVE_LOW),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 		GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NWP, "nwp",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 			    GPIO_ACTIVE_LOW),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 		GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NWE, "nwe",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 			    GPIO_ACTIVE_LOW),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 		GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_ALE, "ale", 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 		GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_CLE, "cle", 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 		GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 0, "data", 0, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 		GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 1, "data", 1, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 		GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 2, "data", 2, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 		GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 3, "data", 3, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 		GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 4, "data", 4, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 		GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 5, "data", 5, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 		GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 6, "data", 6, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 		GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 7, "data", 7, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 		{ },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) static struct resource ams_delta_kp_resources[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 	[0] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 		.start	= INT_KEYBOARD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 		.end	= INT_KEYBOARD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 		.flags	= IORESOURCE_IRQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) static const struct matrix_keymap_data ams_delta_keymap_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	.keymap		= ams_delta_keymap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	.keymap_size	= ARRAY_SIZE(ams_delta_keymap),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) static struct omap_kp_platform_data ams_delta_kp_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 	.rows		= 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	.cols		= 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	.keymap_data	= &ams_delta_keymap_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	.delay		= 9,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) static struct platform_device ams_delta_kp_device = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	.name		= "omap-keypad",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	.id		= -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	.dev		= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 		.platform_data = &ams_delta_kp_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 	.num_resources	= ARRAY_SIZE(ams_delta_kp_resources),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	.resource	= ams_delta_kp_resources,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) static struct platform_device ams_delta_lcd_device = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 	.name	= "lcd_ams_delta",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	.id	= -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) static struct gpiod_lookup_table ams_delta_lcd_gpio_table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	.table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 		GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_LCD_VBLEN, "vblen", 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 		GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_LCD_NDISP, "ndisp", 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 		{ },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) static struct gpio_led gpio_leds[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	[LATCH1_PIN_LED_CAMERA] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 		.name		 = "camera",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 		.default_state	 = LEDS_GPIO_DEFSTATE_OFF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) #ifdef CONFIG_LEDS_TRIGGERS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 		.default_trigger = "ams_delta_camera",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 	[LATCH1_PIN_LED_ADVERT] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 		.name		 = "advert",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 		.default_state	 = LEDS_GPIO_DEFSTATE_OFF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 	[LATCH1_PIN_LED_MAIL] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 		.name		 = "email",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 		.default_state	 = LEDS_GPIO_DEFSTATE_OFF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 	[LATCH1_PIN_LED_HANDSFREE] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 		.name		 = "handsfree",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 		.default_state	 = LEDS_GPIO_DEFSTATE_OFF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 	[LATCH1_PIN_LED_VOICEMAIL] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 		.name		 = "voicemail",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 		.default_state	 = LEDS_GPIO_DEFSTATE_OFF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	[LATCH1_PIN_LED_VOICE] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 		.name		 = "voice",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 		.default_state	 = LEDS_GPIO_DEFSTATE_OFF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) static const struct gpio_led_platform_data leds_pdata __initconst = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	.leds		= gpio_leds,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 	.num_leds	= ARRAY_SIZE(gpio_leds),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) static struct gpiod_lookup_table leds_gpio_table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 	.table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 		GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_CAMERA, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 				LATCH1_PIN_LED_CAMERA, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 		GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_ADVERT, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 				LATCH1_PIN_LED_ADVERT, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 		GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_MAIL, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 				LATCH1_PIN_LED_MAIL, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 		GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_HANDSFREE, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 				LATCH1_PIN_LED_HANDSFREE, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 		GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_VOICEMAIL, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 				LATCH1_PIN_LED_VOICEMAIL, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 		GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_VOICE, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 				LATCH1_PIN_LED_VOICE, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 		{ },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) #ifdef CONFIG_LEDS_TRIGGERS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) DEFINE_LED_TRIGGER(ams_delta_camera_led_trigger);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) static struct platform_device ams_delta_audio_device = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 	.name   = "ams-delta-audio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 	.id     = -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) static struct gpiod_lookup_table ams_delta_audio_gpio_table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	.table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 		GPIO_LOOKUP(OMAP_GPIO_LABEL, AMS_DELTA_GPIO_PIN_HOOK_SWITCH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 			    "hook_switch", 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 		GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_MODEM_CODEC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 			    "modem_codec", 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 		GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_HANDSFREE_MUTE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 			    "handsfree_mute", 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 		GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_HANDSET_MUTE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 			    "handset_mute", 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 		{ },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) static struct platform_device cx20442_codec_device = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 	.name   = "cx20442-codec",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 	.id     = -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) static struct resource ams_delta_serio_resources[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 		.flags	= IORESOURCE_IRQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 		 * Initialize IRQ resource with invalid IRQ number.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 		 * It will be replaced with dynamically allocated GPIO IRQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 		 * obtained from GPIO chip as soon as the chip is available.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 		.start	= -EINVAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 		.end	= -EINVAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) static struct platform_device ams_delta_serio_device = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 	.name		= "ams-delta-serio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 	.id		= PLATFORM_DEVID_NONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 	.dev		= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 		 * Initialize .platform_data explicitly with NULL to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 		 * indicate it is going to be used.  It will be replaced
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 		 * with FIQ buffer address as soon as FIQ is initialized.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 		.platform_data = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 	.num_resources	= ARRAY_SIZE(ams_delta_serio_resources),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 	.resource	= ams_delta_serio_resources,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) static struct regulator_consumer_supply keybrd_pwr_consumers[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 	 * Initialize supply .dev_name with NULL.  It will be replaced
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 	 * with serio dev_name() as soon as the serio device is registered.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 	REGULATOR_SUPPLY("vcc", NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) static struct regulator_init_data keybrd_pwr_initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 	.constraints		= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 		.valid_ops_mask		= REGULATOR_CHANGE_STATUS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 	.num_consumer_supplies	= ARRAY_SIZE(keybrd_pwr_consumers),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 	.consumer_supplies	= keybrd_pwr_consumers,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) static struct fixed_voltage_config keybrd_pwr_config = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 	.supply_name		= "keybrd_pwr",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 	.microvolts		= 5000000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 	.init_data		= &keybrd_pwr_initdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) static struct platform_device keybrd_pwr_device = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 	.name	= "reg-fixed-voltage",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) 	.id	= PLATFORM_DEVID_AUTO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 	.dev	= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) 		.platform_data	= &keybrd_pwr_config,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) static struct gpiod_lookup_table keybrd_pwr_gpio_table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 	.table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 		GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_KEYBRD_PWR, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 			    GPIO_ACTIVE_HIGH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 		{ },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) static struct platform_device *ams_delta_devices[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 	&latch1_gpio_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 	&latch2_gpio_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 	&ams_delta_kp_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 	&ams_delta_audio_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 	&ams_delta_serio_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 	&ams_delta_nand_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 	&ams_delta_lcd_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 	&cx20442_codec_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) static struct gpiod_lookup_table *ams_delta_gpio_tables[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 	&ams_delta_nreset_gpiod_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 	&ams_delta_audio_gpio_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 	&keybrd_pwr_gpio_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 	&ams_delta_lcd_gpio_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 	&ams_delta_nand_gpio_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573)  * Some drivers may not use GPIO lookup tables but need to be provided
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574)  * with GPIO numbers.  The same applies to GPIO based IRQ lines - some
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575)  * drivers may even not use GPIO layer but expect just IRQ numbers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576)  * We could either define GPIO lookup tables then use them on behalf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577)  * of those devices, or we can use GPIO driver level methods for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578)  * identification of GPIO and IRQ numbers. For the purpose of the latter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579)  * defina a helper function which identifies GPIO chips by their labels.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) static int gpiochip_match_by_label(struct gpio_chip *chip, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 	char *label = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 	return !strcmp(label, chip->label);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) static struct gpiod_hog ams_delta_gpio_hogs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 	GPIO_HOG(LATCH2_LABEL, LATCH2_PIN_KEYBRD_DATAOUT, "keybrd_dataout",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 		 GPIO_ACTIVE_HIGH, GPIOD_OUT_LOW),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) 	{},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) static struct plat_serial8250_port ams_delta_modem_ports[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597)  * Obtain MODEM IRQ GPIO descriptor using its hardware pin
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598)  * number and assign related IRQ number to the MODEM port.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599)  * Keep the GPIO descriptor open so nobody steps in.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) static void __init modem_assign_irq(struct gpio_chip *chip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) 	struct gpio_desc *gpiod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) 	gpiod = gpiochip_request_own_desc(chip, AMS_DELTA_GPIO_PIN_MODEM_IRQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) 					  "modem_irq", GPIO_ACTIVE_HIGH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) 					  GPIOD_IN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) 	if (IS_ERR(gpiod)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 		pr_err("%s: modem IRQ GPIO request failed (%ld)\n", __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 		       PTR_ERR(gpiod));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 		ams_delta_modem_ports[0].irq = gpiod_to_irq(gpiod);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617)  * The purpose of this function is to take care of proper initialization of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618)  * devices and data structures which depend on GPIO lines provided by OMAP GPIO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619)  * banks but their drivers don't use GPIO lookup tables or GPIO layer at all.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620)  * The function may be called as soon as OMAP GPIO devices are probed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621)  * Since that happens at postcore_initcall, it can be called successfully
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622)  * from init_machine or later.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623)  * Dependent devices may be registered from within this function or later.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) static void __init omap_gpio_deps_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) 	struct gpio_chip *chip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) 	chip = gpiochip_find(OMAP_GPIO_LABEL, gpiochip_match_by_label);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) 	if (!chip) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) 		pr_err("%s: OMAP GPIO chip not found\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) 	 * Start with FIQ initialization as it may have to request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) 	 * and release successfully each OMAP GPIO pin in turn.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) 	ams_delta_init_fiq(chip, &ams_delta_serio_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) 	modem_assign_irq(chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645)  * Initialize latch2 pins with values which are safe for dependent on-board
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646)  * devices or useful for their successull initialization even before GPIO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647)  * driver takes control over the latch pins:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648)  * - LATCH2_PIN_LCD_VBLEN	= 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649)  * - LATCH2_PIN_LCD_NDISP	= 0	Keep LCD device powered off before its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650)  *					driver takes control over it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651)  * - LATCH2_PIN_NAND_NCE	= 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652)  * - LATCH2_PIN_NAND_NWP	= 0	Keep NAND device down and write-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653)  *					protected before its driver takes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654)  *					control over it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655)  * - LATCH2_PIN_KEYBRD_PWR	= 0	Keep keyboard powered off before serio
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656)  *					driver takes control over it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657)  * - LATCH2_PIN_KEYBRD_DATAOUT	= 0	Keep low to avoid corruption of first
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658)  *					byte of data received from attached
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659)  *					keyboard when serio device is probed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660)  *					the pin is also hogged low by the latch2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661)  *					GPIO driver as soon as it is ready.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662)  * - LATCH2_PIN_MODEM_NRESET	= 1	Enable voice MODEM device, allowing for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663)  *					its successful probe even before a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664)  *					regulator it depends on, which in turn
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665)  *					takes control over the pin, is set up.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666)  * - LATCH2_PIN_MODEM_CODEC	= 1	Attach voice MODEM CODEC data port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667)  *					to the MODEM so the CODEC is under
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668)  *					control even if audio driver doesn't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669)  *					take it over.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) static void __init ams_delta_latch2_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) 	u16 latch2 = 1 << LATCH2_PIN_MODEM_NRESET | 1 << LATCH2_PIN_MODEM_CODEC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) 	__raw_writew(latch2, LATCH2_VIRT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) static void __init ams_delta_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) 	struct platform_device *leds_pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) 	/* mux pins for uarts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) 	omap_cfg_reg(UART1_TX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) 	omap_cfg_reg(UART1_RTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) 	/* parallel camera interface */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) 	omap_cfg_reg(H19_1610_CAM_EXCLK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) 	omap_cfg_reg(J15_1610_CAM_LCLK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) 	omap_cfg_reg(L18_1610_CAM_VS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) 	omap_cfg_reg(L15_1610_CAM_HS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) 	omap_cfg_reg(L19_1610_CAM_D0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) 	omap_cfg_reg(K14_1610_CAM_D1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) 	omap_cfg_reg(K15_1610_CAM_D2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) 	omap_cfg_reg(K19_1610_CAM_D3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) 	omap_cfg_reg(K18_1610_CAM_D4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) 	omap_cfg_reg(J14_1610_CAM_D5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) 	omap_cfg_reg(J19_1610_CAM_D6);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) 	omap_cfg_reg(J18_1610_CAM_D7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) 	omap_gpio_deps_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) 	ams_delta_latch2_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) 	gpiod_add_hogs(ams_delta_gpio_hogs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) 	omap_serial_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) 	omap_register_i2c_bus(1, 100, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) 	omap1_usb_init(&ams_delta_usb_config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) #ifdef CONFIG_LEDS_TRIGGERS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) 	led_trigger_register_simple("ams_delta_camera",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) 			&ams_delta_camera_led_trigger);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) 	platform_add_devices(ams_delta_devices, ARRAY_SIZE(ams_delta_devices));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) 	 * As soon as regulator consumers have been registered, assign their
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) 	 * dev_names to consumer supply entries of respective regulators.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) 	keybrd_pwr_consumers[0].dev_name =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) 			dev_name(&ams_delta_serio_device.dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) 	 * Once consumer supply entries are populated with dev_names,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) 	 * register regulator devices.  At this stage only the keyboard
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) 	 * power regulator has its consumer supply table fully populated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) 	platform_device_register(&keybrd_pwr_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) 	 * As soon as GPIO consumers have been registered, assign
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) 	 * their dev_names to respective GPIO lookup tables.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) 	ams_delta_audio_gpio_table.dev_id =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) 			dev_name(&ams_delta_audio_device.dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) 	keybrd_pwr_gpio_table.dev_id = dev_name(&keybrd_pwr_device.dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) 	ams_delta_nand_gpio_table.dev_id = dev_name(&ams_delta_nand_device.dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) 	ams_delta_lcd_gpio_table.dev_id = dev_name(&ams_delta_lcd_device.dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) 	 * Once GPIO lookup tables are populated with dev_names, register them.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) 	gpiod_add_lookup_tables(ams_delta_gpio_tables,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) 				ARRAY_SIZE(ams_delta_gpio_tables));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) 	leds_pdev = gpio_led_register_device(PLATFORM_DEVID_NONE, &leds_pdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) 	if (!IS_ERR_OR_NULL(leds_pdev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) 		leds_gpio_table.dev_id = dev_name(&leds_pdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) 		gpiod_add_lookup_table(&leds_gpio_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) 	omap_writew(omap_readw(ARM_RSTCT1) | 0x0004, ARM_RSTCT1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) 	omapfb_set_lcd_config(&ams_delta_lcd_config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) static void modem_pm(struct uart_port *port, unsigned int state, unsigned old)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) 	struct modem_private_data *priv = port->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) 	if (!priv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) 	if (IS_ERR(priv->regulator))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) 	if (state == old)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) 	if (state == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) 		ret = regulator_enable(priv->regulator);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) 	else if (old == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) 		ret = regulator_disable(priv->regulator);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) 		ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) 		dev_warn(port->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) 			 "ams_delta modem_pm: failed to %sable regulator: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) 			 state ? "dis" : "en", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) static struct plat_serial8250_port ams_delta_modem_ports[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) 		.membase	= IOMEM(MODEM_VIRT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) 		.mapbase	= MODEM_PHYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) 		.irq		= IRQ_NOTCONNECTED, /* changed later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) 		.flags		= UPF_BOOT_AUTOCONF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) 		.irqflags	= IRQF_TRIGGER_RISING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) 		.iotype		= UPIO_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) 		.regshift	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) 		.uartclk	= BASE_BAUD * 16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) 		.pm		= modem_pm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) 		.private_data	= &modem_priv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) 	{ },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) static struct platform_device ams_delta_modem_device = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) 	.name	= "serial8250",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) 	.id	= PLAT8250_DEV_PLATFORM1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) 	.dev		= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) 		.platform_data = ams_delta_modem_ports,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) static int __init modem_nreset_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) 	err = platform_device_register(&modem_nreset_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) 		pr_err("Couldn't register the modem regulator device\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819)  * This function expects MODEM IRQ number already assigned to the port.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820)  * The MODEM device requires its RESET# pin kept high during probe.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821)  * That requirement can be fulfilled in several ways:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822)  * - with a descriptor of already functional modem_nreset regulator
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823)  *   assigned to the MODEM private data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824)  * - with the regulator not yet controlled by modem_pm function but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825)  *   already enabled by default on probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826)  * - before the modem_nreset regulator is probed, with the pin already
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827)  *   set high explicitly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828)  * The last one is already guaranteed by ams_delta_latch2_init() called
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829)  * from machine_init.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830)  * In order to avoid taking over ttyS0 device slot, the MODEM device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831)  * should be registered after OMAP serial ports.  Since those ports
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832)  * are registered at arch_initcall, this function can be called safely
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833)  * at arch_initcall_sync earliest.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) static int __init ams_delta_modem_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) 	if (!machine_is_ams_delta())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) 	omap_cfg_reg(M14_1510_GPIO2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) 	/* Initialize the modem_nreset regulator consumer before use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) 	modem_priv.regulator = ERR_PTR(-ENODEV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) 	err = platform_device_register(&ams_delta_modem_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) arch_initcall_sync(ams_delta_modem_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) static int __init late_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) 	err = modem_nreset_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) 	 * Once the modem device is registered, the modem_nreset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) 	 * regulator can be requested on behalf of that device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) 	modem_priv.regulator = regulator_get(&ams_delta_modem_device.dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) 			"RESET#");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) 	if (IS_ERR(modem_priv.regulator)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) 		err = PTR_ERR(modem_priv.regulator);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) 		goto unregister;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) unregister:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) 	platform_device_unregister(&ams_delta_modem_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) static void __init ams_delta_init_late(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) 	omap1_init_late();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) 	late_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) static void __init ams_delta_map_io(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) 	omap15xx_map_io();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) 	iotable_init(ams_delta_io_desc, ARRAY_SIZE(ams_delta_io_desc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) MACHINE_START(AMS_DELTA, "Amstrad E3 (Delta)")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) 	/* Maintainer: Jonathan McDowell <noodles@earth.li> */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) 	.atag_offset	= 0x100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) 	.map_io		= ams_delta_map_io,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) 	.init_early	= omap1_init_early,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) 	.init_irq	= omap1_init_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) 	.handle_irq	= omap1_handle_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) 	.init_machine	= ams_delta_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) 	.init_late	= ams_delta_init_late,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) 	.init_time	= omap1_timer_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) 	.restart	= omap1_restart,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) MACHINE_END