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)  * Support for HTC Magician PDA phones:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    4)  * i-mate JAM, O2 Xda mini, Orange SPV M500, Qtek s100, Qtek s110
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    5)  * and T-Mobile MDA Compact.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    7)  * Copyright (c) 2006-2007 Philipp Zabel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    9)  * Based on hx4700.c, spitz.c and others.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   10)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   12) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   13) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   14) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   15) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   16) #include <linux/gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   17) #include <linux/gpio/machine.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   18) #include <linux/gpio_keys.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   19) #include <linux/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   20) #include <linux/mfd/htc-pasic3.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   21) #include <linux/mtd/physmap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   22) #include <linux/pda_power.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   23) #include <linux/platform_data/gpio-htc-egpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   24) #include <linux/pwm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   25) #include <linux/pwm_backlight.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   26) #include <linux/regulator/driver.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   27) #include <linux/regulator/fixed.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   28) #include <linux/regulator/gpio-regulator.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   29) #include <linux/regulator/machine.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   30) #include <linux/platform_data/i2c-pxa.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   32) #include <mach/hardware.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/system_info.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   37) #include "pxa27x.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   38) #include <mach/magician.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   39) #include <linux/platform_data/video-pxafb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   40) #include <linux/platform_data/mmc-pxamci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   41) #include <linux/platform_data/irda-pxaficp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   42) #include <linux/platform_data/usb-ohci-pxa27x.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   44) #include <linux/regulator/max1586.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   46) #include <linux/platform_data/pxa2xx_udc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   48) #include "udc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   49) #include "pxa27x-udc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   50) #include "devices.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   51) #include "generic.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   53) #include <linux/spi/spi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   54) #include <linux/spi/pxa2xx_spi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   55) #include <linux/spi/ads7846.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   57) static unsigned long magician_pin_config[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   59) 	/* SDRAM and Static Memory I/O Signals */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   60) 	GPIO20_nSDCS_2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   61) 	GPIO21_nSDCS_3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   62) 	GPIO15_nCS_1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   63) 	GPIO78_nCS_2,	/* PASIC3 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   64) 	GPIO79_nCS_3,	/* EGPIO CPLD */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   65) 	GPIO80_nCS_4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   66) 	GPIO33_nCS_5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   68) 	/* I2C UDA1380 + OV9640 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   69) 	GPIO117_I2C_SCL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   70) 	GPIO118_I2C_SDA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   72) 	/* PWM 0 - LCD backlight */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   73) 	GPIO16_PWM0_OUT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   75) 	/* I2S UDA1380 capture */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   76) 	GPIO28_I2S_BITCLK_OUT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   77) 	GPIO29_I2S_SDATA_IN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   78) 	GPIO31_I2S_SYNC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   79) 	GPIO113_I2S_SYSCLK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   81) 	/* SSP 1 UDA1380 playback */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   82) 	GPIO23_SSP1_SCLK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   83) 	GPIO24_SSP1_SFRM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   84) 	GPIO25_SSP1_TXD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   86) 	/* SSP 2 TSC2046 touchscreen */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   87) 	GPIO19_SSP2_SCLK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   88) 	MFP_CFG_OUT(GPIO14, AF0, DRIVE_HIGH),	/* frame as GPIO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   89) 	GPIO89_SSP2_TXD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   90) 	GPIO88_SSP2_RXD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   92) 	/* MMC/SD/SDHC slot */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   93) 	GPIO32_MMC_CLK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   94) 	GPIO92_MMC_DAT_0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   95) 	GPIO109_MMC_DAT_1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   96) 	GPIO110_MMC_DAT_2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   97) 	GPIO111_MMC_DAT_3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   98) 	GPIO112_MMC_CMD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  100) 	/* LCD */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  101) 	GPIOxx_LCD_TFT_16BPP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  103) 	/* QCI camera interface */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  104) 	GPIO12_CIF_DD_7,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  105) 	GPIO17_CIF_DD_6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  106) 	GPIO50_CIF_DD_3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  107) 	GPIO51_CIF_DD_2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  108) 	GPIO52_CIF_DD_4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  109) 	GPIO53_CIF_MCLK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  110) 	GPIO54_CIF_PCLK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  111) 	GPIO55_CIF_DD_1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  112) 	GPIO81_CIF_DD_0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  113) 	GPIO82_CIF_DD_5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  114) 	GPIO84_CIF_FV,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  115) 	GPIO85_CIF_LV,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  117) 	/* Magician specific input GPIOs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  118) 	GPIO9_GPIO,	/* unknown */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  119) 	GPIO10_GPIO,	/* GSM_IRQ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  120) 	GPIO13_GPIO,	/* CPLD_IRQ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  121) 	GPIO107_GPIO,	/* DS1WM_IRQ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  122) 	GPIO108_GPIO,	/* GSM_READY */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  123) 	GPIO115_GPIO,	/* nPEN_IRQ */
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  127)  * IrDA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  128)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  130) static struct pxaficp_platform_data magician_ficp_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  131) 	.gpio_pwdown		= GPIO83_MAGICIAN_nIR_EN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  132) 	.transceiver_cap	= IR_SIRMODE | IR_OFF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  133) 	.gpio_pwdown_inverted	= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  134) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  136) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  137)  * GPIO Keys
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  138)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  140) #define INIT_KEY(_code, _gpio, _desc)	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  141) 	{				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  142) 		.code	= KEY_##_code,	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  143) 		.gpio	= _gpio,	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  144) 		.desc	= _desc,	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  145) 		.type	= EV_KEY,	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  146) 		.wakeup	= 1,		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  147) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  149) static struct gpio_keys_button magician_button_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  150) 	INIT_KEY(POWER,      GPIO0_MAGICIAN_KEY_POWER,      "Power button"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  151) 	INIT_KEY(ESC,        GPIO37_MAGICIAN_KEY_HANGUP,    "Hangup button"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  152) 	INIT_KEY(F10,        GPIO38_MAGICIAN_KEY_CONTACTS,  "Contacts button"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  153) 	INIT_KEY(CALENDAR,   GPIO90_MAGICIAN_KEY_CALENDAR,  "Calendar button"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  154) 	INIT_KEY(CAMERA,     GPIO91_MAGICIAN_KEY_CAMERA,    "Camera button"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  155) 	INIT_KEY(UP,         GPIO93_MAGICIAN_KEY_UP,        "Up button"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  156) 	INIT_KEY(DOWN,       GPIO94_MAGICIAN_KEY_DOWN,      "Down button"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  157) 	INIT_KEY(LEFT,       GPIO95_MAGICIAN_KEY_LEFT,      "Left button"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  158) 	INIT_KEY(RIGHT,      GPIO96_MAGICIAN_KEY_RIGHT,     "Right button"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  159) 	INIT_KEY(KPENTER,    GPIO97_MAGICIAN_KEY_ENTER,     "Action button"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  160) 	INIT_KEY(RECORD,     GPIO98_MAGICIAN_KEY_RECORD,    "Record button"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  161) 	INIT_KEY(VOLUMEUP,   GPIO100_MAGICIAN_KEY_VOL_UP,   "Volume up"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  162) 	INIT_KEY(VOLUMEDOWN, GPIO101_MAGICIAN_KEY_VOL_DOWN, "Volume down"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  163) 	INIT_KEY(PHONE,      GPIO102_MAGICIAN_KEY_PHONE,    "Phone button"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  164) 	INIT_KEY(PLAY,       GPIO99_MAGICIAN_HEADPHONE_IN,  "Headset button"),
^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) static struct gpio_keys_platform_data gpio_keys_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  168) 	.buttons	= magician_button_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  169) 	.nbuttons	= ARRAY_SIZE(magician_button_table),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  170) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  172) static struct platform_device gpio_keys = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  173) 	.name	= "gpio-keys",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  174) 	.dev	= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  175) 		.platform_data = &gpio_keys_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  176) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  177) 	.id	= -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  178) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  180) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  181)  * EGPIO (Xilinx CPLD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  182)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  183)  * 32-bit aligned 8-bit registers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  184)  * 16 possible registers (reg windows size), only 7 used:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  185)  * 3x output, 1x irq, 3x input
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  186)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  188) static struct resource egpio_resources[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  189) 	[0] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  190) 		.start	= PXA_CS3_PHYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  191) 		.end	= PXA_CS3_PHYS + 0x20 - 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  192) 		.flags	= IORESOURCE_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  193) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  194) 	[1] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  195) 		.start	= PXA_GPIO_TO_IRQ(GPIO13_MAGICIAN_CPLD_IRQ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  196) 		.end	= PXA_GPIO_TO_IRQ(GPIO13_MAGICIAN_CPLD_IRQ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  197) 		.flags	= IORESOURCE_IRQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  198) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  199) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  201) static struct htc_egpio_chip egpio_chips[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  202) 	[0] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  203) 		.reg_start	= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  204) 		.gpio_base	= MAGICIAN_EGPIO(0, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  205) 		.num_gpios	= 24,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  206) 		.direction	= HTC_EGPIO_OUTPUT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  207) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  208) 		 * Depends on modules configuration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  209) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  210) 		.initial_values	= 0x40, /* EGPIO_MAGICIAN_GSM_RESET */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  211) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  212) 	[1] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  213) 		.reg_start	= 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  214) 		.gpio_base	= MAGICIAN_EGPIO(4, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  215) 		.num_gpios	= 24,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  216) 		.direction	= HTC_EGPIO_INPUT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  217) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  218) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  220) static struct htc_egpio_platform_data egpio_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  221) 	.reg_width	= 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  222) 	.bus_width	= 32,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  223) 	.irq_base	= IRQ_BOARD_START,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  224) 	.num_irqs	= 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  225) 	.ack_register	= 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  226) 	.chip		= egpio_chips,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  227) 	.num_chips	= ARRAY_SIZE(egpio_chips),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  228) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  230) static struct platform_device egpio = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  231) 	.name		= "htc-egpio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  232) 	.id		= -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  233) 	.resource	= egpio_resources,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  234) 	.num_resources	= ARRAY_SIZE(egpio_resources),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  235) 	.dev = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  236) 		.platform_data = &egpio_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  237) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  238) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  240) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  241)  * PXAFB LCD - Toppoly TD028STEB1 or Samsung LTP280QV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  242)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  243) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  244) static struct pxafb_mode_info toppoly_modes[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  245) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  246) 		.pixclock	= 96153,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  247) 		.bpp		= 16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  248) 		.xres		= 240,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  249) 		.yres		= 320,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  250) 		.hsync_len	= 11,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  251) 		.vsync_len	= 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  252) 		.left_margin	= 19,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  253) 		.upper_margin	= 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  254) 		.right_margin	= 10,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  255) 		.lower_margin	= 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  256) 		.sync		= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  257) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  258) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  260) static struct pxafb_mode_info samsung_modes[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  261) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  262) 		.pixclock	= 226469,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  263) 		.bpp		= 16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  264) 		.xres		= 240,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  265) 		.yres		= 320,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  266) 		.hsync_len	= 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  267) 		.vsync_len	= 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  268) 		.left_margin	= 9,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  269) 		.upper_margin	= 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  270) 		.right_margin	= 9,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  271) 		.lower_margin	= 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  272) 		.sync	= FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  273) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  274) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  275) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  276) static void toppoly_lcd_power(int on, struct fb_var_screeninfo *si)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  277) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  278) 	pr_debug("Toppoly LCD power: %s\n", on ? "on" : "off");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  279) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  280) 	if (on) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  281) 		gpio_set_value(EGPIO_MAGICIAN_TOPPOLY_POWER, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  282) 		gpio_set_value(GPIO106_MAGICIAN_LCD_DCDC_NRESET, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  283) 		udelay(2000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  284) 		gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  285) 		udelay(2000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  286) 		/* FIXME: enable LCDC here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  287) 		udelay(2000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  288) 		gpio_set_value(GPIO104_MAGICIAN_LCD_VOFF_EN, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  289) 		udelay(2000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  290) 		gpio_set_value(GPIO105_MAGICIAN_LCD_VON_EN, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  291) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  292) 		msleep(15);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  293) 		gpio_set_value(GPIO105_MAGICIAN_LCD_VON_EN, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  294) 		udelay(500);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  295) 		gpio_set_value(GPIO104_MAGICIAN_LCD_VOFF_EN, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  296) 		udelay(1000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  297) 		gpio_set_value(GPIO106_MAGICIAN_LCD_DCDC_NRESET, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  298) 		gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  299) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  300) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  302) static void samsung_lcd_power(int on, struct fb_var_screeninfo *si)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  303) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  304) 	pr_debug("Samsung LCD power: %s\n", on ? "on" : "off");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  305) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  306) 	if (on) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  307) 		if (system_rev < 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  308) 			gpio_set_value(GPIO75_MAGICIAN_SAMSUNG_POWER, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  309) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  310) 			gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  311) 		mdelay(6);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  312) 		gpio_set_value(GPIO106_MAGICIAN_LCD_DCDC_NRESET, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  313) 		mdelay(6);	/* Avdd -> Voff >5ms */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  314) 		gpio_set_value(GPIO104_MAGICIAN_LCD_VOFF_EN, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  315) 		mdelay(16);	/* Voff -> Von >(5+10)ms */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  316) 		gpio_set_value(GPIO105_MAGICIAN_LCD_VON_EN, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  317) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  318) 		gpio_set_value(GPIO105_MAGICIAN_LCD_VON_EN, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  319) 		mdelay(16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  320) 		gpio_set_value(GPIO104_MAGICIAN_LCD_VOFF_EN, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  321) 		mdelay(6);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  322) 		gpio_set_value(GPIO106_MAGICIAN_LCD_DCDC_NRESET, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  323) 		mdelay(6);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  324) 		if (system_rev < 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  325) 			gpio_set_value(GPIO75_MAGICIAN_SAMSUNG_POWER, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  326) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  327) 			gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  328) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  329) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  330) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  331) static struct pxafb_mach_info toppoly_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  332) 	.modes			= toppoly_modes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  333) 	.num_modes		= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  334) 	.fixed_modes		= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  335) 	.lcd_conn		= LCD_COLOR_TFT_16BPP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  336) 	.pxafb_lcd_power	= toppoly_lcd_power,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  337) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  338) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  339) static struct pxafb_mach_info samsung_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  340) 	.modes			= samsung_modes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  341) 	.num_modes		= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  342) 	.fixed_modes		= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  343) 	.lcd_conn		= LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  344) 		LCD_ALTERNATE_MAPPING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  345) 	.pxafb_lcd_power	= samsung_lcd_power,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  346) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  348) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  349)  * Backlight
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  350)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  351) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  352) static struct pwm_lookup magician_pwm_lookup[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  353) 	PWM_LOOKUP("pxa27x-pwm.0", 0, "pwm-backlight", NULL, 30923,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  354) 		   PWM_POLARITY_NORMAL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  355) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  356) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  357)  /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  358)  * fixed regulator for pwm_backlight
^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) static struct regulator_consumer_supply pwm_backlight_supply[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  362) 	REGULATOR_SUPPLY("power", "pwm_backlight"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  363) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  364) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  365) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  366) static struct gpio magician_bl_gpios[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  367) 	{ EGPIO_MAGICIAN_BL_POWER,	GPIOF_DIR_OUT, "Backlight power" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  368) 	{ EGPIO_MAGICIAN_BL_POWER2,	GPIOF_DIR_OUT, "Backlight power 2" },
^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 int magician_backlight_init(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  372) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  373) 	return gpio_request_array(ARRAY_AND_SIZE(magician_bl_gpios));
^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 int magician_backlight_notify(struct device *dev, int brightness)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  377) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  378) 	pr_debug("Brightness = %i\n", brightness);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  379) 	gpio_set_value(EGPIO_MAGICIAN_BL_POWER, brightness);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  380) 	if (brightness >= 200) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  381) 		gpio_set_value(EGPIO_MAGICIAN_BL_POWER2, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  382) 		return brightness - 72;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  383) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  384) 		gpio_set_value(EGPIO_MAGICIAN_BL_POWER2, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  385) 		return brightness;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  386) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  387) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  388) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  389) static void magician_backlight_exit(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  390) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  391) 	gpio_free_array(ARRAY_AND_SIZE(magician_bl_gpios));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  392) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  393) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  394) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  395)  * LCD PWM backlight (main)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  396)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  397)  * MP1521 frequency should be:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  398)  *	100-400 Hz = 2 .5*10^6 - 10 *10^6 ns
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  399)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  400) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  401) static struct platform_pwm_backlight_data backlight_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  402) 	.max_brightness	= 272,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  403) 	.dft_brightness	= 100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  404) 	.init		= magician_backlight_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  405) 	.notify		= magician_backlight_notify,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  406) 	.exit		= magician_backlight_exit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  407) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  408) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  409) static struct platform_device backlight = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  410) 	.name	= "pwm-backlight",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  411) 	.id	= -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  412) 	.dev	= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  413) 		.parent		= &pxa27x_device_pwm0.dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  414) 		.platform_data	= &backlight_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  415) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  416) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  417) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  418) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  419)  * GPIO LEDs, Phone keys backlight, vibra
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  420)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  421) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  422) static struct gpio_led gpio_leds[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  423) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  424) 		.name = "magician::vibra",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  425) 		.default_trigger = "none",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  426) 		.gpio = GPIO22_MAGICIAN_VIBRA_EN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  427) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  428) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  429) 		.name = "magician::phone_bl",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  430) 		.default_trigger = "backlight",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  431) 		.gpio = GPIO103_MAGICIAN_LED_KP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  432) 	},
^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) static struct gpio_led_platform_data gpio_led_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  436) 	.leds = gpio_leds,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  437) 	.num_leds = ARRAY_SIZE(gpio_leds),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  438) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  439) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  440) static struct platform_device leds_gpio = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  441) 	.name	= "leds-gpio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  442) 	.id	= -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  443) 	.dev	= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  444) 		.platform_data = &gpio_led_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  445) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  446) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  447) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  448) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  449)  * PASIC3 with DS1WM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  450)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  451) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  452) static struct resource pasic3_resources[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  453) 	[0] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  454) 		.start	= PXA_CS2_PHYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  455) 		.end	= PXA_CS2_PHYS + 0x1b,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  456) 		.flags	= IORESOURCE_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  457) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  458) 	/* No IRQ handler in the PASIC3, DS1WM needs an external IRQ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  459) 	[1] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  460) 		.start	= PXA_GPIO_TO_IRQ(GPIO107_MAGICIAN_DS1WM_IRQ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  461) 		.end	= PXA_GPIO_TO_IRQ(GPIO107_MAGICIAN_DS1WM_IRQ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  462) 		.flags	= IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  463) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  464) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  465) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  466) static struct pasic3_platform_data pasic3_platform_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  467) 	.clock_rate = 4000000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  468) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  469) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  470) static struct platform_device pasic3 = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  471) 	.name		= "pasic3",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  472) 	.id		= -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  473) 	.num_resources	= ARRAY_SIZE(pasic3_resources),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  474) 	.resource	= pasic3_resources,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  475) 	.dev = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  476) 		.platform_data = &pasic3_platform_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  477) 	},
^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)  * PXA UDC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  482)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  483) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  484) static void magician_udc_command(int cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  485) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  486) 	if (cmd == PXA2XX_UDC_CMD_CONNECT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  487) 		UP2OCR |= UP2OCR_DPPUE | UP2OCR_DPPUBE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  488) 	else if (cmd == PXA2XX_UDC_CMD_DISCONNECT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  489) 		UP2OCR &= ~(UP2OCR_DPPUE | UP2OCR_DPPUBE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  490) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  491) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  492) static struct pxa2xx_udc_mach_info magician_udc_info __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  493) 	.udc_command	= magician_udc_command,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  494) 	.gpio_pullup	= GPIO27_MAGICIAN_USBC_PUEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  495) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  496) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  497) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  498)  * USB device VBus detection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  499)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  500) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  501) static struct resource gpio_vbus_resource = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  502) 	.flags	= IORESOURCE_IRQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  503) 	.start	= IRQ_MAGICIAN_VBUS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  504) 	.end	= IRQ_MAGICIAN_VBUS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  505) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  506) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  507) static struct gpiod_lookup_table gpio_vbus_gpiod_table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  508) 	.dev_id = "gpio-vbus",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  509) 	.table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  510) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  511) 		 * EGPIO on register 4 index 1, the second EGPIO chip
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  512) 		 * starts at register 4 so this will be at index 1 on that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  513) 		 * chip.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  514) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  515) 		GPIO_LOOKUP("htc-egpio-1", 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  516) 			    "vbus", GPIO_ACTIVE_HIGH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  517) 		GPIO_LOOKUP("gpio-pxa", GPIO27_MAGICIAN_USBC_PUEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  518) 			    "pullup", GPIO_ACTIVE_HIGH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  519) 		{ },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  520) 	},
^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 platform_device gpio_vbus = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  524) 	.name		= "gpio-vbus",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  525) 	.id		= -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  526) 	.num_resources	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  527) 	.resource	= &gpio_vbus_resource,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  528) };
^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)  * External power
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  532)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  533) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  534) static int magician_supply_init(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  535) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  536) 	int ret = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  537) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  538) 	ret = gpio_request(EGPIO_MAGICIAN_CABLE_TYPE, "Cable is AC charger");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  539) 	if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  540) 		pr_err("Cannot request AC/USB charger GPIO (%i)\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  541) 		goto err_ac;
^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) 	ret = gpio_request(EGPIO_MAGICIAN_CABLE_INSERTED, "Cable inserted");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  545) 	if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  546) 		pr_err("Cannot request cable detection GPIO (%i)\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  547) 		goto err_usb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  548) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  549) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  550) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  551) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  552) err_usb:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  553) 	gpio_free(EGPIO_MAGICIAN_CABLE_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  554) err_ac:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  555) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  556) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  557) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  558) static void magician_set_charge(int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  559) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  560) 	if (flags & PDA_POWER_CHARGE_AC) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  561) 		pr_debug("Charging from AC\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  562) 		gpio_set_value(EGPIO_MAGICIAN_NICD_CHARGE, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  563) 	} else if (flags & PDA_POWER_CHARGE_USB) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  564) 		pr_debug("Charging from USB\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  565) 		gpio_set_value(EGPIO_MAGICIAN_NICD_CHARGE, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  566) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  567) 		pr_debug("Charging disabled\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  568) 		gpio_set_value(EGPIO_MAGICIAN_NICD_CHARGE, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  569) 	}
^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) static int magician_is_ac_online(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  573) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  574) 	return gpio_get_value(EGPIO_MAGICIAN_CABLE_INSERTED) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  575) 		gpio_get_value(EGPIO_MAGICIAN_CABLE_TYPE); /* AC=1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  576) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  577) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  578) static int magician_is_usb_online(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  579) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  580) 	return gpio_get_value(EGPIO_MAGICIAN_CABLE_INSERTED) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  581) 		(!gpio_get_value(EGPIO_MAGICIAN_CABLE_TYPE)); /* USB=0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  582) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  583) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  584) static void magician_supply_exit(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  585) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  586) 	gpio_free(EGPIO_MAGICIAN_CABLE_INSERTED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  587) 	gpio_free(EGPIO_MAGICIAN_CABLE_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  588) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  589) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  590) static char *magician_supplicants[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  591) 	"ds2760-battery.0", "backup-battery"
^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 pda_power_pdata power_supply_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  595) 	.init			= magician_supply_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  596) 	.exit			= magician_supply_exit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  597) 	.is_ac_online		= magician_is_ac_online,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  598) 	.is_usb_online		= magician_is_usb_online,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  599) 	.set_charge		= magician_set_charge,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  600) 	.supplied_to		= magician_supplicants,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  601) 	.num_supplicants	= ARRAY_SIZE(magician_supplicants),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  602) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  603) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  604) static struct resource power_supply_resources[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  605) 	[0] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  606) 		.name	= "ac",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  607) 		.flags	= IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  608) 			IORESOURCE_IRQ_LOWEDGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  609) 		.start	= IRQ_MAGICIAN_VBUS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  610) 		.end	= IRQ_MAGICIAN_VBUS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  611) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  612) 	[1] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  613) 		.name	= "usb",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  614) 		.flags	= IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  615) 			IORESOURCE_IRQ_LOWEDGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  616) 		.start	= IRQ_MAGICIAN_VBUS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  617) 		.end	= IRQ_MAGICIAN_VBUS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  618) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  619) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  620) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  621) static struct platform_device power_supply = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  622) 	.name	= "pda-power",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  623) 	.id	= -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  624) 	.dev = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  625) 		.platform_data = &power_supply_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  626) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  627) 	.resource	= power_supply_resources,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  628) 	.num_resources	= ARRAY_SIZE(power_supply_resources),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  629) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  630) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  631) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  632)  * Battery charger
^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) static struct regulator_consumer_supply bq24022_consumers[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  636) 	REGULATOR_SUPPLY("vbus_draw", NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  637) 	REGULATOR_SUPPLY("ac_draw", NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  638) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  639) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  640) static struct regulator_init_data bq24022_init_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  641) 	.constraints = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  642) 		.max_uA		= 500000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  643) 		.valid_ops_mask	= REGULATOR_CHANGE_CURRENT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  644) 			REGULATOR_CHANGE_STATUS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  645) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  646) 	.num_consumer_supplies	= ARRAY_SIZE(bq24022_consumers),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  647) 	.consumer_supplies	= bq24022_consumers,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  648) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  649) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  650) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  651) static enum gpiod_flags bq24022_gpiod_gflags[] = { GPIOD_OUT_LOW };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  652) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  653) static struct gpio_regulator_state bq24022_states[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  654) 	{ .value = 100000, .gpios = (0 << 0) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  655) 	{ .value = 500000, .gpios = (1 << 0) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  656) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  657) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  658) static struct gpio_regulator_config bq24022_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  659) 	.supply_name		= "bq24022",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  660) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  661) 	.enabled_at_boot	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  662) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  663) 	.gflags = bq24022_gpiod_gflags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  664) 	.ngpios = ARRAY_SIZE(bq24022_gpiod_gflags),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  665) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  666) 	.states			= bq24022_states,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  667) 	.nr_states		= ARRAY_SIZE(bq24022_states),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  668) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  669) 	.type			= REGULATOR_CURRENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  670) 	.init_data		= &bq24022_init_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  671) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  672) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  673) static struct platform_device bq24022 = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  674) 	.name	= "gpio-regulator",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  675) 	.id	= -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  676) 	.dev	= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  677) 		.platform_data = &bq24022_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  678) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  679) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  680) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  681) static struct gpiod_lookup_table bq24022_gpiod_table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  682) 	.dev_id = "gpio-regulator",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  683) 	.table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  684) 		GPIO_LOOKUP("gpio-pxa", EGPIO_MAGICIAN_BQ24022_ISET2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  685) 			    NULL, GPIO_ACTIVE_HIGH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  686) 		GPIO_LOOKUP("gpio-pxa", GPIO30_MAGICIAN_BQ24022_nCHARGE_EN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  687) 			    "enable", GPIO_ACTIVE_LOW),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  688) 		{ },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  689) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  690) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  691) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  692) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  693)  * fixed regulator for ads7846
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  694)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  695) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  696) static struct regulator_consumer_supply ads7846_supply =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  697) 	REGULATOR_SUPPLY("vcc", "spi2.0");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  698) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  699) static struct regulator_init_data vads7846_regulator = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  700) 	.constraints	= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  701) 		.valid_ops_mask	= REGULATOR_CHANGE_STATUS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  702) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  703) 	.num_consumer_supplies	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  704) 	.consumer_supplies	= &ads7846_supply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  705) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  706) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  707) static struct fixed_voltage_config vads7846 = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  708) 	.supply_name	= "vads7846",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  709) 	.microvolts	= 3300000, /* probably */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  710) 	.startup_delay	= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  711) 	.init_data	= &vads7846_regulator,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  712) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  713) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  714) static struct platform_device vads7846_device = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  715) 	.name	= "reg-fixed-voltage",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  716) 	.id	= -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  717) 	.dev	= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  718) 		.platform_data	= &vads7846,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  719) 	},
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  723)  * Vcore regulator MAX1587A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  724)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  725) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  726) static struct regulator_consumer_supply magician_max1587a_consumers[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  727) 	REGULATOR_SUPPLY("vcc_core", NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  728) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  729) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  730) static struct regulator_init_data magician_max1587a_v3_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  731) 	.constraints = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  732) 		.name		= "vcc_core range",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  733) 		.min_uV		= 700000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  734) 		.max_uV		= 1475000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  735) 		.always_on	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  736) 		.valid_ops_mask	= REGULATOR_CHANGE_VOLTAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  737) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  738) 	.consumer_supplies	= magician_max1587a_consumers,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  739) 	.num_consumer_supplies	= ARRAY_SIZE(magician_max1587a_consumers),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  740) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  741) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  742) static struct max1586_subdev_data magician_max1587a_subdevs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  743) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  744) 		.name		= "vcc_core",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  745) 		.id		= MAX1586_V3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  746) 		.platform_data	= &magician_max1587a_v3_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  747) 	}
^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) static struct max1586_platform_data magician_max1587a_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  751) 	.subdevs     = magician_max1587a_subdevs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  752) 	.num_subdevs = ARRAY_SIZE(magician_max1587a_subdevs),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  753) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  754) 	 * NOTICE measured directly on the PCB (board_id == 0x3a), but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  755) 	 * if R24 is present, it will boost the voltage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  756) 	 * (write 1.475V, get 1.645V and smoke)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  757) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  758) 	.v3_gain     = MAX1586_GAIN_NO_R24,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  759) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  760) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  761) static struct i2c_board_info magician_pwr_i2c_board_info[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  762) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  763) 		I2C_BOARD_INFO("max1586", 0x14),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  764) 		.platform_data	= &magician_max1587a_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  765) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  766) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  767) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  768) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  769)  * MMC/SD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  770)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  771) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  772) static int magician_mci_init(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  773) 	irq_handler_t detect_irq, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  774) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  775) 	return request_irq(IRQ_MAGICIAN_SD, detect_irq, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  776) 		"mmc card detect", data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  777) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  778) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  779) static void magician_mci_exit(struct device *dev, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  780) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  781) 	free_irq(IRQ_MAGICIAN_SD, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  782) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  783) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  784) static struct pxamci_platform_data magician_mci_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  785) 	.ocr_mask		= MMC_VDD_32_33|MMC_VDD_33_34,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  786) 	.init			= magician_mci_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  787) 	.exit			= magician_mci_exit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  788) 	.gpio_card_ro_invert	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  789) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  790) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  791) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  792)  * Write protect on EGPIO register 5 index 4, this is on the second HTC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  793)  * EGPIO chip which starts at register 4, so we need offset 8+4=12 on that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  794)  * particular chip.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  795)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  796) #define EGPIO_MAGICIAN_nSD_READONLY_OFFSET 12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  797) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  798)  * Power on EGPIO register 2 index 0, so this is on the first HTC EGPIO chip
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  799)  * starting at register 0 so we need offset 2*8+0 = 16 on that chip.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  800)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  801) #define EGPIO_MAGICIAN_nSD_POWER_OFFSET 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  802) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  803) static struct gpiod_lookup_table magician_mci_gpio_table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  804) 	.dev_id = "pxa2xx-mci.0",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  805) 	.table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  806) 		GPIO_LOOKUP("htc-egpio-1", EGPIO_MAGICIAN_nSD_READONLY_OFFSET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  807) 			    "wp", GPIO_ACTIVE_HIGH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  808) 		GPIO_LOOKUP("htc-egpio-0", EGPIO_MAGICIAN_nSD_POWER_OFFSET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  809) 			    "power", GPIO_ACTIVE_HIGH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  810) 		{ },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  811) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  812) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  813) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  814) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  815)  * USB OHCI
^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) static struct pxaohci_platform_data magician_ohci_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  819) 	.port_mode	= PMM_PERPORT_MODE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  820) 	/* port1: CSR Bluetooth, port2: OTG with UDC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  821) 	.flags		= ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  822) 	.power_budget	= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  823) 	.power_on_delay = 100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  824) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  825) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  826) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  827)  * StrataFlash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  828)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  829) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  830) static int magician_flash_init(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  831) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  832) 	int ret = gpio_request(EGPIO_MAGICIAN_FLASH_VPP, "flash Vpp enable");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  833) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  834) 	if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  835) 		pr_err("Cannot request flash enable GPIO (%i)\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  836) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  837) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  838) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  839) 	ret = gpio_direction_output(EGPIO_MAGICIAN_FLASH_VPP, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  840) 	if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  841) 		pr_err("Cannot set direction for flash enable (%i)\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  842) 		gpio_free(EGPIO_MAGICIAN_FLASH_VPP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  843) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  844) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  845) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  846) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  847) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  848) static void magician_set_vpp(struct platform_device *pdev, int vpp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  849) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  850) 	gpio_set_value(EGPIO_MAGICIAN_FLASH_VPP, vpp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  851) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  852) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  853) static void magician_flash_exit(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  854) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  855) 	gpio_free(EGPIO_MAGICIAN_FLASH_VPP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  856) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  857) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  858) static struct resource strataflash_resource = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  859) 	.start	= PXA_CS0_PHYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  860) 	.end	= PXA_CS0_PHYS + SZ_64M - 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  861) 	.flags	= IORESOURCE_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  862) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  863) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  864) static struct mtd_partition magician_flash_parts[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  865) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  866) 		.name		= "Bootloader",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  867) 		.offset		= 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  868) 		.size		= 0x40000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  869) 		.mask_flags	= MTD_WRITEABLE, /* EXPERIMENTAL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  870) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  871) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  872) 		.name		= "Linux Kernel",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  873) 		.offset		= 0x40000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  874) 		.size		= MTDPART_SIZ_FULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  875) 	},
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  879)  * physmap-flash driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  880)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  881) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  882) static struct physmap_flash_data strataflash_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  883) 	.width		= 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  884) 	.init		= magician_flash_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  885) 	.set_vpp	= magician_set_vpp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  886) 	.exit		= magician_flash_exit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  887) 	.parts		= magician_flash_parts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  888) 	.nr_parts	= ARRAY_SIZE(magician_flash_parts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  889) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  890) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  891) static struct platform_device strataflash = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  892) 	.name		= "physmap-flash",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  893) 	.id		= -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  894) 	.resource	= &strataflash_resource,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  895) 	.num_resources	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  896) 	.dev = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  897) 		.platform_data = &strataflash_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  898) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  899) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  900) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  901) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  902)  * PXA I2C main controller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  903)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  904) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  905) static struct i2c_pxa_platform_data i2c_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  906) 	/* OV9640 I2C device doesn't support fast mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  907) 	.fast_mode	= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  908) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  909) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  910) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  911)  * PXA I2C power controller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  912)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  913) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  914) static struct i2c_pxa_platform_data magician_i2c_power_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  915) 	.fast_mode	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  916) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  917) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  918) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  919)  * Touchscreen
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  920)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  921) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  922) static struct ads7846_platform_data ads7846_pdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  923) 	.model		= 7846,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  924) 	.x_plate_ohms	= 317,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  925) 	.y_plate_ohms	= 500,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  926) 	.pressure_max	= 1023,	/* with x plate ohms it will overflow 255 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  927) 	.debounce_max	= 3,	/* first readout is always bad */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  928) 	.debounce_tol	= 30,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  929) 	.debounce_rep	= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  930) 	.gpio_pendown	= GPIO115_MAGICIAN_nPEN_IRQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  931) 	.keep_vref_on	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  932) 	.wakeup		= true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  933) 	.vref_delay_usecs		= 100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  934) 	.penirq_recheck_delay_usecs	= 100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  935) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  936) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  937) struct pxa2xx_spi_chip tsc2046_chip_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  938) 	.tx_threshold	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  939) 	.rx_threshold	= 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  940) 	.timeout	= 64,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  941) 	/* NOTICE must be GPIO, incompatibility with hw PXA SPI framing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  942) 	.gpio_cs	= GPIO14_MAGICIAN_TSC2046_CS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  943) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  944) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  945) static struct pxa2xx_spi_controller magician_spi_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  946) 	.num_chipselect	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  947) 	.enable_dma	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  948) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  949) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  950) static struct spi_board_info ads7846_spi_board_info[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  951) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  952) 		.modalias		= "ads7846",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  953) 		.bus_num		= 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  954) 		.max_speed_hz		= 2500000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  955) 		.platform_data		= &ads7846_pdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  956) 		.controller_data	= &tsc2046_chip_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  957) 		.irq = PXA_GPIO_TO_IRQ(GPIO115_MAGICIAN_nPEN_IRQ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  958) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  959) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  960) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  961) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  962)  * Platform devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  963)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  964) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  965) static struct platform_device *devices[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  966) 	&gpio_keys,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  967) 	&egpio,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  968) 	&backlight,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  969) 	&pasic3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  970) 	&bq24022,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  971) 	&gpio_vbus,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  972) 	&power_supply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  973) 	&strataflash,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  974) 	&leds_gpio,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  975) 	&vads7846_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  976) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  977) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  978) static struct gpio magician_global_gpios[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  979) 	{ GPIO13_MAGICIAN_CPLD_IRQ, GPIOF_IN, "CPLD_IRQ" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  980) 	{ GPIO107_MAGICIAN_DS1WM_IRQ, GPIOF_IN, "DS1WM_IRQ" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  981) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  982) 	/* NOTICE valid LCD init sequence */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  983) 	{ GPIO106_MAGICIAN_LCD_DCDC_NRESET, GPIOF_OUT_INIT_LOW, "LCD DCDC nreset" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  984) 	{ GPIO104_MAGICIAN_LCD_VOFF_EN, GPIOF_OUT_INIT_LOW, "LCD VOFF enable" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  985) 	{ GPIO105_MAGICIAN_LCD_VON_EN, GPIOF_OUT_INIT_LOW, "LCD VON enable" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  986) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  987) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  988) static void __init magician_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  989) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  990) 	void __iomem *cpld;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  991) 	int lcd_select;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  992) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  993) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  994) 	pxa2xx_mfp_config(ARRAY_AND_SIZE(magician_pin_config));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  995) 	err = gpio_request_array(ARRAY_AND_SIZE(magician_global_gpios));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  996) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  997) 		pr_err("magician: Failed to request global GPIOs: %d\n", err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  998) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  999) 	pxa_set_ffuart_info(NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) 	pxa_set_btuart_info(NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) 	pwm_add_table(magician_pwm_lookup, ARRAY_SIZE(magician_pwm_lookup));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) 	pxa_set_ficp_info(&magician_ficp_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) 	pxa27x_set_i2c_power_info(&magician_i2c_power_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) 	pxa_set_i2c_info(&i2c_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) 	i2c_register_board_info(1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) 		ARRAY_AND_SIZE(magician_pwr_i2c_board_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) 	gpiod_add_lookup_table(&magician_mci_gpio_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) 	pxa_set_mci_info(&magician_mci_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) 	pxa_set_ohci_info(&magician_ohci_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) 	pxa_set_udc_info(&magician_udc_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) 	/* Check LCD type we have */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) 	cpld = ioremap(PXA_CS3_PHYS, 0x1000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) 	if (cpld) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) 		u8 board_id = __raw_readb(cpld + 0x14);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) 		iounmap(cpld);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) 		system_rev = board_id & 0x7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) 		lcd_select = board_id & 0x8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) 		pr_info("LCD type: %s\n", lcd_select ? "Samsung" : "Toppoly");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) 		if (lcd_select && (system_rev < 3))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) 			/* NOTICE valid LCD init sequence */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) 			gpio_request_one(GPIO75_MAGICIAN_SAMSUNG_POWER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) 				GPIOF_OUT_INIT_LOW, "Samsung LCD Power");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) 		pxa_set_fb_info(NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) 			lcd_select ? &samsung_info : &toppoly_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) 		pr_err("LCD detection: CPLD mapping failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) 	pxa2xx_set_spi_info(2, &magician_spi_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) 	spi_register_board_info(ARRAY_AND_SIZE(ads7846_spi_board_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) 	regulator_register_always_on(0, "power", pwm_backlight_supply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) 		ARRAY_SIZE(pwm_backlight_supply), 5000000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) 	gpiod_add_lookup_table(&bq24022_gpiod_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) 	gpiod_add_lookup_table(&gpio_vbus_gpiod_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) 	platform_add_devices(ARRAY_AND_SIZE(devices));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) MACHINE_START(MAGICIAN, "HTC Magician")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) 	.atag_offset	= 0x100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) 	.map_io		= pxa27x_map_io,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) 	.nr_irqs	= MAGICIAN_NR_IRQS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) 	.init_irq	= pxa27x_init_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) 	.handle_irq	= pxa27x_handle_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) 	.init_machine	= magician_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) 	.init_time	= pxa_timer_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) 	.restart	= pxa_restart,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) MACHINE_END