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
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) //
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) // Copyright (c) 2003-2005 Simtec Electronics
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) //   Ben Dooks <ben@simtec.co.uk>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) //
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) // https://www.handhelds.org/projects/h1940.html
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/memblock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/timer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/serial_core.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/serial_s3c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/gpio/machine.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <linux/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <linux/gpio_keys.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/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #include <linux/leds.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #include <linux/pda_power.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #include <linux/s3c_adc_battery.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #include <video/platform_lcd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #include <linux/mmc/host.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #include <asm/irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #include <asm/mach-types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #include <asm/mach/arch.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #include <asm/mach/map.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #include <asm/mach/irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #include <linux/platform_data/i2c-s3c2410.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #include <linux/platform_data/mmc-s3cmci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #include <linux/platform_data/touchscreen-s3c2410.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #include <linux/platform_data/usb-s3c2410_udc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #include <sound/uda1380.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #include <linux/platform_data/fb-s3c2410.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) #include "map.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #include "hardware-s3c24xx.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #include "regs-clock.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) #include "regs-gpio.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) #include "gpio-samsung.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) #include "cpu.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) #include "devs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) #include "gpio-cfg.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) #include "pm.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) #include "s3c24xx.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) #include "h1940.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) #define H1940_LATCH		((void __force __iomem *)0xF8000000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) #define H1940_PA_LATCH		S3C2410_CS2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) #define H1940_LATCH_BIT(x)	(1 << ((x) + 16 - S3C_GPIO_END))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) #define S3C24XX_PLL_MDIV_SHIFT         (12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) #define S3C24XX_PLL_PDIV_SHIFT         (4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) #define S3C24XX_PLL_SDIV_SHIFT         (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) static struct map_desc h1940_iodesc[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	[0] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		.virtual	= (unsigned long)H1940_LATCH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		.pfn		= __phys_to_pfn(H1940_PA_LATCH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 		.length		= SZ_16K,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		.type		= MT_DEVICE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) #define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) static struct s3c2410_uartcfg h1940_uartcfgs[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	[0] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		.hwport	     = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		.flags	     = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		.ucon	     = 0x3c5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		.ulcon	     = 0x03,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		.ufcon	     = 0x51,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	[1] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		.hwport	     = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		.flags	     = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		.ucon	     = 0x245,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		.ulcon	     = 0x03,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		.ufcon	     = 0x00,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	/* IR port */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	[2] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		.hwport	     = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		.flags	     = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		.uart_flags  = UPF_CONS_FLOW,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		.ucon	     = 0x3c5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		.ulcon	     = 0x43,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		.ufcon	     = 0x51,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) /* Board control latch control */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) static unsigned int latch_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) static void h1940_latch_control(unsigned int clear, unsigned int set)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	local_irq_save(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	latch_state &= ~clear;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	latch_state |= set;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	__raw_writel(latch_state, H1940_LATCH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	local_irq_restore(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) static inline int h1940_gpiolib_to_latch(int offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	return 1 << (offset + 16);
^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) static void h1940_gpiolib_latch_set(struct gpio_chip *chip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 					unsigned offset, int value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	int latch_bit = h1940_gpiolib_to_latch(offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	h1940_latch_control(value ? 0 : latch_bit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		value ? latch_bit : 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) static int h1940_gpiolib_latch_output(struct gpio_chip *chip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 					unsigned offset, int value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	h1940_gpiolib_latch_set(chip, offset, value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) static int h1940_gpiolib_latch_get(struct gpio_chip *chip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 					unsigned offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	return (latch_state >> (offset + 16)) & 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) static struct gpio_chip h1940_latch_gpiochip = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	.base			= H1940_LATCH_GPIO(0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	.owner			= THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	.label			= "H1940_LATCH",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	.ngpio			= 16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	.direction_output	= h1940_gpiolib_latch_output,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	.set			= h1940_gpiolib_latch_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	.get			= h1940_gpiolib_latch_get,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) static struct s3c2410_udc_mach_info h1940_udc_cfg __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	.vbus_pin		= S3C2410_GPG(5),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	.vbus_pin_inverted	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	.pullup_pin		= H1940_LATCH_USB_DP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) static struct s3c2410_ts_mach_info h1940_ts_cfg __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		.delay = 10000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 		.presc = 49,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 		.oversampling_shift = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		.cfg_gpio = s3c24xx_ts_cfg_gpio,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)  * Set lcd on or off
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) static struct s3c2410fb_display h1940_lcd __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	.lcdcon5=	S3C2410_LCDCON5_FRM565 | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 			S3C2410_LCDCON5_INVVLINE | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 			S3C2410_LCDCON5_HWSWP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	.type =		S3C2410_LCDCON1_TFT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	.width =	240,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	.height =	320,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	.pixclock =	260000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	.xres =		240,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	.yres =		320,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	.bpp =		16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	.left_margin =	8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	.right_margin =	20,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	.hsync_len =	4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	.upper_margin =	8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	.lower_margin = 7,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	.vsync_len =	1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) static struct s3c2410fb_mach_info h1940_fb_info __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	.displays = &h1940_lcd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	.num_displays = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	.default_display = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	.lpcsel =	0x02,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	.gpccon =	0xaa940659,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	.gpccon_mask =	0xffffc0f0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	.gpccon_reg =	S3C2410_GPCCON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	.gpcup =	0x0000ffff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	.gpcup_mask =	0xffffffff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	.gpcup_reg =	S3C2410_GPCUP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	.gpdcon =	0xaa84aaa0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	.gpdcon_mask =	0xffffffff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	.gpdcon_reg =	S3C2410_GPDCON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	.gpdup =	0x0000faff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	.gpdup_mask =	0xffffffff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	.gpdup_reg =	S3C2410_GPDUP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) static int power_supply_init(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	return gpio_request(S3C2410_GPF(2), "cable plugged");
^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 int h1940_is_ac_online(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	return !gpio_get_value(S3C2410_GPF(2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) static void power_supply_exit(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	gpio_free(S3C2410_GPF(2));
^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) static char *h1940_supplicants[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	"main-battery",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	"backup-battery",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) static struct pda_power_pdata power_supply_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	.init			= power_supply_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	.is_ac_online		= h1940_is_ac_online,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	.exit			= power_supply_exit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	.supplied_to		= h1940_supplicants,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	.num_supplicants	= ARRAY_SIZE(h1940_supplicants),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) static struct resource power_supply_resources[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	[0] = DEFINE_RES_NAMED(IRQ_EINT2, 1, "ac", IORESOURCE_IRQ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 			| IORESOURCE_IRQ_LOWEDGE | IORESOURCE_IRQ_HIGHEDGE),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) static struct platform_device power_supply = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	.name		= "pda-power",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	.id		= -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	.dev		= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 				.platform_data =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 					&power_supply_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	.resource	= power_supply_resources,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	.num_resources	= ARRAY_SIZE(power_supply_resources),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) static const struct s3c_adc_bat_thresh bat_lut_noac[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	{ .volt = 4070, .cur = 162, .level = 100},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	{ .volt = 4040, .cur = 165, .level = 95},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	{ .volt = 4016, .cur = 164, .level = 90},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	{ .volt = 3996, .cur = 166, .level = 85},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	{ .volt = 3971, .cur = 168, .level = 80},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	{ .volt = 3951, .cur = 168, .level = 75},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	{ .volt = 3931, .cur = 170, .level = 70},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	{ .volt = 3903, .cur = 172, .level = 65},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	{ .volt = 3886, .cur = 172, .level = 60},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	{ .volt = 3858, .cur = 176, .level = 55},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	{ .volt = 3842, .cur = 176, .level = 50},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	{ .volt = 3818, .cur = 176, .level = 45},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	{ .volt = 3789, .cur = 180, .level = 40},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	{ .volt = 3769, .cur = 180, .level = 35},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	{ .volt = 3749, .cur = 184, .level = 30},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	{ .volt = 3732, .cur = 184, .level = 25},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	{ .volt = 3716, .cur = 184, .level = 20},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	{ .volt = 3708, .cur = 184, .level = 15},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	{ .volt = 3716, .cur = 96, .level = 10},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	{ .volt = 3700, .cur = 96, .level = 5},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	{ .volt = 3684, .cur = 96, .level = 0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) static const struct s3c_adc_bat_thresh bat_lut_acin[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	{ .volt = 4130, .cur = 0, .level = 100},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	{ .volt = 3982, .cur = 0, .level = 50},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	{ .volt = 3854, .cur = 0, .level = 10},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	{ .volt = 3841, .cur = 0, .level = 0},
^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 int h1940_bat_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	ret = gpio_request(H1940_LATCH_SM803_ENABLE, "h1940-charger-enable");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	gpio_direction_output(H1940_LATCH_SM803_ENABLE, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) static void h1940_bat_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	gpio_free(H1940_LATCH_SM803_ENABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) static void h1940_enable_charger(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	gpio_set_value(H1940_LATCH_SM803_ENABLE, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) static void h1940_disable_charger(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	gpio_set_value(H1940_LATCH_SM803_ENABLE, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) static struct s3c_adc_bat_pdata h1940_bat_cfg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	.init = h1940_bat_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	.exit = h1940_bat_exit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	.enable_charger = h1940_enable_charger,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	.disable_charger = h1940_disable_charger,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	.gpio_charge_finished = S3C2410_GPF(3),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	.gpio_inverted = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	.lut_noac = bat_lut_noac,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	.lut_noac_cnt = ARRAY_SIZE(bat_lut_noac),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	.lut_acin = bat_lut_acin,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	.lut_acin_cnt = ARRAY_SIZE(bat_lut_acin),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	.volt_channel = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	.current_channel = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	.volt_mult = 4056,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	.current_mult = 1893,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	.internal_impedance = 200,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	.backup_volt_channel = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	/* TODO Check backup volt multiplier */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	.backup_volt_mult = 4056,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	.backup_volt_min = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	.backup_volt_max = 4149288
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) static struct platform_device h1940_battery = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	.name             = "s3c-adc-battery",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	.id               = -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	.dev = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 		.parent = &s3c_device_adc.dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 		.platform_data = &h1940_bat_cfg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) static DEFINE_SPINLOCK(h1940_blink_spin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) int h1940_led_blink_set(struct gpio_desc *desc, int state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	unsigned long *delay_on, unsigned long *delay_off)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	int blink_gpio, check_gpio1, check_gpio2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	int gpio = desc ? desc_to_gpio(desc) : -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	switch (gpio) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	case H1940_LATCH_LED_GREEN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 		blink_gpio = S3C2410_GPA(7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 		check_gpio1 = S3C2410_GPA(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 		check_gpio2 = S3C2410_GPA(3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	case H1940_LATCH_LED_RED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 		blink_gpio = S3C2410_GPA(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 		check_gpio1 = S3C2410_GPA(7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 		check_gpio2 = S3C2410_GPA(3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 		blink_gpio = S3C2410_GPA(3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 		check_gpio1 = S3C2410_GPA(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 		check_gpio2 = S3C2410_GPA(7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	if (delay_on && delay_off && !*delay_on && !*delay_off)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 		*delay_on = *delay_off = 500;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 	spin_lock(&h1940_blink_spin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	switch (state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	case GPIO_LED_NO_BLINK_LOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	case GPIO_LED_NO_BLINK_HIGH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 		if (!gpio_get_value(check_gpio1) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 		    !gpio_get_value(check_gpio2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 			gpio_set_value(H1940_LATCH_LED_FLASH, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 		gpio_set_value(blink_gpio, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 		if (gpio_is_valid(gpio))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 			gpio_set_value(gpio, state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	case GPIO_LED_BLINK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 		if (gpio_is_valid(gpio))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 			gpio_set_value(gpio, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 		gpio_set_value(H1940_LATCH_LED_FLASH, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 		gpio_set_value(blink_gpio, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 		break;
^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) 	spin_unlock(&h1940_blink_spin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) EXPORT_SYMBOL(h1940_led_blink_set);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) static struct gpio_led h1940_leds_desc[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 		.name			= "Green",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 		.default_trigger	= "main-battery-full",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 		.gpio			= H1940_LATCH_LED_GREEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 		.retain_state_suspended	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 		.name			= "Red",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 		.default_trigger
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 			= "main-battery-charging-blink-full-solid",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 		.gpio			= H1940_LATCH_LED_RED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 		.retain_state_suspended	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) static struct gpio_led_platform_data h1940_leds_pdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	.num_leds	= ARRAY_SIZE(h1940_leds_desc),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 	.leds		= h1940_leds_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 	.gpio_blink_set	= h1940_led_blink_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) static struct platform_device h1940_device_leds = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 	.name	= "leds-gpio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	.id	= -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 	.dev	= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 			.platform_data = &h1940_leds_pdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) static struct platform_device h1940_device_bluetooth = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	.name             = "h1940-bt",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	.id               = -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) static void h1940_set_mmc_power(unsigned char power_mode, unsigned short vdd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	s3c24xx_mci_def_set_power(power_mode, vdd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 	switch (power_mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 	case MMC_POWER_OFF:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 		gpio_set_value(H1940_LATCH_SD_POWER, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 	case MMC_POWER_UP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 	case MMC_POWER_ON:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 		gpio_set_value(H1940_LATCH_SD_POWER, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 		break;
^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) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) static struct s3c24xx_mci_pdata h1940_mmc_cfg __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	.set_power     = h1940_set_mmc_power,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	.ocr_avail     = MMC_VDD_32_33,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) static struct gpiod_lookup_table h1940_mmc_gpio_table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 	.dev_id = "s3c2410-sdi",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 	.table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 		/* Card detect S3C2410_GPF(5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 		GPIO_LOOKUP("GPIOF", 5, "cd", GPIO_ACTIVE_LOW),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 		/* Write protect S3C2410_GPH(8) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 		GPIO_LOOKUP("GPIOH", 8, "wp", GPIO_ACTIVE_LOW),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 		/* bus pins */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 		GPIO_LOOKUP_IDX("GPIOE",  5, "bus", 0, GPIO_ACTIVE_HIGH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 		GPIO_LOOKUP_IDX("GPIOE",  6, "bus", 1, GPIO_ACTIVE_HIGH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 		GPIO_LOOKUP_IDX("GPIOE",  7, "bus", 2, GPIO_ACTIVE_HIGH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 		GPIO_LOOKUP_IDX("GPIOE",  8, "bus", 3, GPIO_ACTIVE_HIGH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 		GPIO_LOOKUP_IDX("GPIOE",  9, "bus", 4, GPIO_ACTIVE_HIGH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 		GPIO_LOOKUP_IDX("GPIOE", 10, "bus", 5, GPIO_ACTIVE_HIGH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 		{ },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) static struct gpiod_lookup_table h1940_audio_gpio_table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 	.dev_id = "h1940-audio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 	.table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 		GPIO_LOOKUP("H1940_LATCH",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 			    H1940_LATCH_AUDIO_POWER - H1940_LATCH_GPIO(0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 			    "speaker-power", GPIO_ACTIVE_HIGH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 		GPIO_LOOKUP("GPIOG", 4, "hp", GPIO_ACTIVE_HIGH),
^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) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) static struct platform_device h1940_audio = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 	.name = "h1940-audio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 	.id   = -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) static struct pwm_lookup h1940_pwm_lookup[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 	PWM_LOOKUP("samsung-pwm", 0, "pwm-backlight", NULL, 36296,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 		   PWM_POLARITY_NORMAL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) static int h1940_backlight_init(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 	gpio_request(S3C2410_GPB(0), "Backlight");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 	gpio_direction_output(S3C2410_GPB(0), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 	s3c_gpio_setpull(S3C2410_GPB(0), S3C_GPIO_PULL_NONE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 	s3c_gpio_cfgpin(S3C2410_GPB(0), S3C2410_GPB0_TOUT0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 	gpio_set_value(H1940_LATCH_MAX1698_nSHUTDOWN, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 	return 0;
^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 int h1940_backlight_notify(struct device *dev, int brightness)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 	if (!brightness) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 		gpio_direction_output(S3C2410_GPB(0), 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 		gpio_set_value(H1940_LATCH_MAX1698_nSHUTDOWN, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 		gpio_direction_output(S3C2410_GPB(0), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 		s3c_gpio_setpull(S3C2410_GPB(0), S3C_GPIO_PULL_NONE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 		s3c_gpio_cfgpin(S3C2410_GPB(0), S3C2410_GPB0_TOUT0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 		gpio_set_value(H1940_LATCH_MAX1698_nSHUTDOWN, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 	return brightness;
^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 void h1940_backlight_exit(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) 	gpio_direction_output(S3C2410_GPB(0), 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 	gpio_set_value(H1940_LATCH_MAX1698_nSHUTDOWN, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) }
^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) static struct platform_pwm_backlight_data backlight_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 	.max_brightness = 100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 	.dft_brightness = 50,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 	.init           = h1940_backlight_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 	.notify		= h1940_backlight_notify,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 	.exit           = h1940_backlight_exit,
^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) static struct platform_device h1940_backlight = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 	.name = "pwm-backlight",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 	.dev  = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 		.parent = &samsung_device_pwm.dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 		.platform_data = &backlight_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 	.id   = -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) static void h1940_lcd_power_set(struct plat_lcd_data *pd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 					unsigned int power)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 	int value, retries = 100;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 	if (!power) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 		gpio_set_value(S3C2410_GPC(0), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 		/* wait for 3ac */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 		do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 			value = gpio_get_value(S3C2410_GPC(6));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 		} while (value && retries--);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) 		gpio_set_value(H1940_LATCH_LCD_P2, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 		gpio_set_value(H1940_LATCH_LCD_P3, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 		gpio_set_value(H1940_LATCH_LCD_P4, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 		gpio_direction_output(S3C2410_GPC(1), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 		gpio_direction_output(S3C2410_GPC(4), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 		gpio_set_value(H1940_LATCH_LCD_P1, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 		gpio_set_value(H1940_LATCH_LCD_P0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 		gpio_set_value(S3C2410_GPC(5), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) 		gpio_set_value(H1940_LATCH_LCD_P0, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) 		gpio_set_value(H1940_LATCH_LCD_P1, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 		gpio_direction_input(S3C2410_GPC(1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 		gpio_direction_input(S3C2410_GPC(4));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) 		mdelay(10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 		s3c_gpio_cfgpin(S3C2410_GPC(1), S3C_GPIO_SFN(2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) 		s3c_gpio_cfgpin(S3C2410_GPC(4), S3C_GPIO_SFN(2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) 		gpio_set_value(S3C2410_GPC(5), 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) 		gpio_set_value(S3C2410_GPC(0), 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 		gpio_set_value(H1940_LATCH_LCD_P3, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) 		gpio_set_value(H1940_LATCH_LCD_P2, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 		gpio_set_value(H1940_LATCH_LCD_P4, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 	}
^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 plat_lcd_data h1940_lcd_power_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) 	.set_power      = h1940_lcd_power_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) static struct platform_device h1940_lcd_powerdev = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 	.name                   = "platform-lcd",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 	.dev.parent             = &s3c_device_lcd.dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 	.dev.platform_data      = &h1940_lcd_power_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) static struct uda1380_platform_data uda1380_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 	.gpio_power	= H1940_LATCH_UDA_POWER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) 	.gpio_reset	= S3C2410_GPA(12),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) 	.dac_clk	= UDA1380_DAC_CLK_SYSCLK,
^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) static struct i2c_board_info h1940_i2c_devices[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) 		I2C_BOARD_INFO("uda1380", 0x1a),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) 		.platform_data = &uda1380_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) #define DECLARE_BUTTON(p, k, n, w)	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) 	{				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) 		.gpio		= p,	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) 		.code		= k,	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) 		.desc		= n,	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) 		.wakeup		= w,	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) 		.active_low	= 1,	\
^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) static struct gpio_keys_button h1940_buttons[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) 	DECLARE_BUTTON(S3C2410_GPF(0),       KEY_POWER,          "Power", 1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) 	DECLARE_BUTTON(S3C2410_GPF(6),       KEY_ENTER,         "Select", 1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) 	DECLARE_BUTTON(S3C2410_GPF(7),      KEY_RECORD,         "Record", 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) 	DECLARE_BUTTON(S3C2410_GPG(0),         KEY_F11,       "Calendar", 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) 	DECLARE_BUTTON(S3C2410_GPG(2),         KEY_F12,       "Contacts", 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) 	DECLARE_BUTTON(S3C2410_GPG(3),        KEY_MAIL,           "Mail", 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) 	DECLARE_BUTTON(S3C2410_GPG(6),        KEY_LEFT,     "Left_arrow", 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) 	DECLARE_BUTTON(S3C2410_GPG(7),    KEY_HOMEPAGE,           "Home", 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) 	DECLARE_BUTTON(S3C2410_GPG(8),       KEY_RIGHT,    "Right_arrow", 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) 	DECLARE_BUTTON(S3C2410_GPG(9),          KEY_UP,       "Up_arrow", 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) 	DECLARE_BUTTON(S3C2410_GPG(10),       KEY_DOWN,     "Down_arrow", 0),
^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) static struct gpio_keys_platform_data h1940_buttons_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) 	.buttons	= h1940_buttons,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) 	.nbuttons	= ARRAY_SIZE(h1940_buttons),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) static struct platform_device h1940_dev_buttons = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) 	.name		= "gpio-keys",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) 	.id		= -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) 	.dev		= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) 		.platform_data  = &h1940_buttons_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) static struct platform_device *h1940_devices[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) 	&h1940_dev_buttons,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) 	&s3c_device_ohci,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) 	&s3c_device_lcd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) 	&s3c_device_wdt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) 	&s3c_device_i2c0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) 	&s3c_device_iis,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) 	&s3c_device_usbgadget,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) 	&h1940_device_leds,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) 	&h1940_device_bluetooth,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) 	&s3c_device_sdi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) 	&s3c_device_rtc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) 	&samsung_device_pwm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) 	&h1940_backlight,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) 	&h1940_lcd_powerdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) 	&s3c_device_adc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) 	&s3c_device_ts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) 	&power_supply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) 	&h1940_battery,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) 	&h1940_audio,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) static void __init h1940_map_io(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) 	s3c24xx_init_io(h1940_iodesc, ARRAY_SIZE(h1940_iodesc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) 	s3c24xx_init_uarts(h1940_uartcfgs, ARRAY_SIZE(h1940_uartcfgs));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) 	s3c24xx_set_timer_source(S3C24XX_PWM3, S3C24XX_PWM4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) 	/* setup PM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) #ifdef CONFIG_PM_H1940
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) 	memcpy(phys_to_virt(H1940_SUSPEND_RESUMEAT), h1940_pm_return, 1024);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) 	s3c_pm_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) 	/* Add latch gpio chip, set latch initial value */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) 	h1940_latch_control(0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) 	WARN_ON(gpiochip_add_data(&h1940_latch_gpiochip, NULL));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) static void __init h1940_init_time(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) 	s3c2410_init_clocks(12000000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) 	s3c24xx_timer_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) /* H1940 and RX3715 need to reserve this for suspend */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) static void __init h1940_reserve(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) 	memblock_reserve(0x30003000, 0x1000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) 	memblock_reserve(0x30081000, 0x1000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) static void __init h1940_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) 	u32 tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) 	s3c24xx_fb_set_platdata(&h1940_fb_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) 	gpiod_add_lookup_table(&h1940_mmc_gpio_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) 	gpiod_add_lookup_table(&h1940_audio_gpio_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) 	/* Configure the I2S pins (GPE0...GPE4) in correct mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) 	s3c_gpio_cfgall_range(S3C2410_GPE(0), 5, S3C_GPIO_SFN(2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) 			      S3C_GPIO_PULL_NONE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) 	s3c24xx_mci_set_platdata(&h1940_mmc_cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727)  	s3c24xx_udc_set_platdata(&h1940_udc_cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) 	s3c24xx_ts_set_platdata(&h1940_ts_cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) 	s3c_i2c0_set_platdata(NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) 	/* Turn off suspend on both USB ports, and switch the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) 	 * selectable USB port to USB device mode. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) 	s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) 			      S3C2410_MISCCR_USBSUSPND0 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) 			      S3C2410_MISCCR_USBSUSPND1, 0x0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) 	tmp =   (0x78 << S3C24XX_PLL_MDIV_SHIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) 	      | (0x02 << S3C24XX_PLL_PDIV_SHIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) 	      | (0x03 << S3C24XX_PLL_SDIV_SHIFT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) 	writel(tmp, S3C2410_UPLLCON);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) 	gpio_request(S3C2410_GPC(0), "LCD power");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) 	gpio_request(S3C2410_GPC(1), "LCD power");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) 	gpio_request(S3C2410_GPC(4), "LCD power");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) 	gpio_request(S3C2410_GPC(5), "LCD power");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) 	gpio_request(S3C2410_GPC(6), "LCD power");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) 	gpio_request(H1940_LATCH_LCD_P0, "LCD power");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) 	gpio_request(H1940_LATCH_LCD_P1, "LCD power");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) 	gpio_request(H1940_LATCH_LCD_P2, "LCD power");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) 	gpio_request(H1940_LATCH_LCD_P3, "LCD power");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) 	gpio_request(H1940_LATCH_LCD_P4, "LCD power");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) 	gpio_request(H1940_LATCH_MAX1698_nSHUTDOWN, "LCD power");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) 	gpio_direction_output(S3C2410_GPC(0), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) 	gpio_direction_output(S3C2410_GPC(1), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) 	gpio_direction_output(S3C2410_GPC(4), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) 	gpio_direction_output(S3C2410_GPC(5), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) 	gpio_direction_input(S3C2410_GPC(6));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) 	gpio_direction_output(H1940_LATCH_LCD_P0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) 	gpio_direction_output(H1940_LATCH_LCD_P1, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) 	gpio_direction_output(H1940_LATCH_LCD_P2, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) 	gpio_direction_output(H1940_LATCH_LCD_P3, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) 	gpio_direction_output(H1940_LATCH_LCD_P4, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) 	gpio_direction_output(H1940_LATCH_MAX1698_nSHUTDOWN, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) 	gpio_request(H1940_LATCH_SD_POWER, "SD power");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) 	gpio_direction_output(H1940_LATCH_SD_POWER, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) 	pwm_add_table(h1940_pwm_lookup, ARRAY_SIZE(h1940_pwm_lookup));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) 	platform_add_devices(h1940_devices, ARRAY_SIZE(h1940_devices));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) 	gpio_request(S3C2410_GPA(1), "Red LED blink");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) 	gpio_request(S3C2410_GPA(3), "Blue LED blink");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) 	gpio_request(S3C2410_GPA(7), "Green LED blink");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) 	gpio_request(H1940_LATCH_LED_FLASH, "LED blink");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) 	gpio_direction_output(S3C2410_GPA(1), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) 	gpio_direction_output(S3C2410_GPA(3), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) 	gpio_direction_output(S3C2410_GPA(7), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) 	gpio_direction_output(H1940_LATCH_LED_FLASH, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) 	i2c_register_board_info(0, h1940_i2c_devices,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) 		ARRAY_SIZE(h1940_i2c_devices));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) MACHINE_START(H1940, "IPAQ-H1940")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) 	/* Maintainer: Ben Dooks <ben-linux@fluff.org> */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) 	.atag_offset	= 0x100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) 	.map_io		= h1940_map_io,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) 	.reserve	= h1940_reserve,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) 	.init_irq	= s3c2410_init_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) 	.init_machine	= h1940_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) 	.init_time	= h1940_init_time,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) MACHINE_END