Orange Pi5 kernel

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

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * linux/arch/arm/mach-omap1/board-nokia770.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Modified from board-generic.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <linux/clkdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/gpio/machine.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/mutex.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/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/omapfb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/spi/spi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/spi/ads7846.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/workqueue.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <linux/platform_data/keypad-omap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include <linux/platform_data/lcd-mipid.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include <linux/platform_data/gpio-omap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #include <asm/mach-types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #include <asm/mach/arch.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #include <asm/mach/map.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #include <mach/mux.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #include <mach/hardware.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #include <mach/usb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #include "common.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #include "clock.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #include "mmc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #define ADS7846_PENDOWN_GPIO	15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) static const unsigned int nokia770_keymap[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	KEY(1, 0, GROUP_0 | KEY_UP),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	KEY(2, 0, GROUP_1 | KEY_F5),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	KEY(0, 1, GROUP_0 | KEY_LEFT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	KEY(1, 1, GROUP_0 | KEY_ENTER),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	KEY(2, 1, GROUP_0 | KEY_RIGHT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	KEY(0, 2, GROUP_1 | KEY_ESC),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	KEY(1, 2, GROUP_0 | KEY_DOWN),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	KEY(2, 2, GROUP_1 | KEY_F4),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	KEY(0, 3, GROUP_2 | KEY_F7),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	KEY(1, 3, GROUP_2 | KEY_F8),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	KEY(2, 3, GROUP_2 | KEY_F6),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) static struct resource nokia770_kp_resources[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	[0] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 		.start	= INT_KEYBOARD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 		.end	= INT_KEYBOARD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 		.flags	= IORESOURCE_IRQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) static const struct matrix_keymap_data nokia770_keymap_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	.keymap		= nokia770_keymap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	.keymap_size	= ARRAY_SIZE(nokia770_keymap),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) static struct omap_kp_platform_data nokia770_kp_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	.rows		= 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	.cols		= 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	.keymap_data	= &nokia770_keymap_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	.delay		= 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) static struct platform_device nokia770_kp_device = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	.name		= "omap-keypad",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	.id		= -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	.dev		= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		.platform_data = &nokia770_kp_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	.num_resources	= ARRAY_SIZE(nokia770_kp_resources),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	.resource	= nokia770_kp_resources,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) static struct platform_device *nokia770_devices[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	&nokia770_kp_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) static void mipid_shutdown(struct mipid_platform_data *pdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	if (pdata->nreset_gpio != -1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		printk(KERN_INFO "shutdown LCD\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		gpio_set_value(pdata->nreset_gpio, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		msleep(120);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) static struct mipid_platform_data nokia770_mipid_platform_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	.shutdown = mipid_shutdown,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) static const struct omap_lcd_config nokia770_lcd_config __initconst = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	.ctrl_name	= "hwa742",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) static void __init mipid_dev_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	nokia770_mipid_platform_data.nreset_gpio = 13;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	nokia770_mipid_platform_data.data_lines = 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	omapfb_set_lcd_config(&nokia770_lcd_config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) static struct ads7846_platform_data nokia770_ads7846_platform_data __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	.x_max		= 0x0fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	.y_max		= 0x0fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	.x_plate_ohms	= 180,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	.pressure_max	= 255,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	.debounce_max	= 10,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	.debounce_tol	= 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	.debounce_rep	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	.gpio_pendown	= ADS7846_PENDOWN_GPIO,
^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) static struct spi_board_info nokia770_spi_board_info[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	[0] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		.modalias       = "lcd_mipid",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		.bus_num        = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		.chip_select    = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		.max_speed_hz   = 12000000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		.platform_data	= &nokia770_mipid_platform_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	[1] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		.modalias       = "ads7846",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		.bus_num        = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		.chip_select    = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		.max_speed_hz   = 2500000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		.platform_data	= &nokia770_ads7846_platform_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) static void __init hwa742_dev_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	clk_add_alias("hwa_sys_ck", NULL, "bclk", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) /* assume no Mini-AB port */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) static struct omap_usb_config nokia770_usb_config __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	.otg		= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	.register_host	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	.register_dev	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	.hmc_mode	= 16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	.pins[0]	= 6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	.extcon		= "tahvo-usb",
^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) #if IS_ENABLED(CONFIG_MMC_OMAP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) #define NOKIA770_GPIO_MMC_POWER		41
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) #define NOKIA770_GPIO_MMC_SWITCH	23
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) static int nokia770_mmc_set_power(struct device *dev, int slot, int power_on,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 				int vdd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	gpio_set_value(NOKIA770_GPIO_MMC_POWER, power_on);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) static int nokia770_mmc_get_cover_state(struct device *dev, int slot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	return gpio_get_value(NOKIA770_GPIO_MMC_SWITCH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) static struct omap_mmc_platform_data nokia770_mmc2_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	.nr_slots                       = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	.max_freq                       = 12000000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	.slots[0]       = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		.set_power		= nokia770_mmc_set_power,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 		.get_cover_state	= nokia770_mmc_get_cover_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 		.ocr_mask               = MMC_VDD_32_33|MMC_VDD_33_34,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 		.name                   = "mmcblk",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) static struct omap_mmc_platform_data *nokia770_mmc_data[OMAP16XX_NR_MMC];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) static void __init nokia770_mmc_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	ret = gpio_request(NOKIA770_GPIO_MMC_POWER, "MMC power");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	gpio_direction_output(NOKIA770_GPIO_MMC_POWER, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	ret = gpio_request(NOKIA770_GPIO_MMC_SWITCH, "MMC cover");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		gpio_free(NOKIA770_GPIO_MMC_POWER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	gpio_direction_input(NOKIA770_GPIO_MMC_SWITCH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	/* Only the second MMC controller is used */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	nokia770_mmc_data[1] = &nokia770_mmc2_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	omap1_init_mmc(nokia770_mmc_data, OMAP16XX_NR_MMC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) static inline void nokia770_mmc_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) #if IS_ENABLED(CONFIG_I2C_CBUS_GPIO)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) static struct gpiod_lookup_table nokia770_cbus_gpio_table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	.dev_id = "i2c-cbus-gpio.2",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	.table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		GPIO_LOOKUP_IDX("mpuio", 9, NULL, 0, 0), /* clk */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		GPIO_LOOKUP_IDX("mpuio", 10, NULL, 1, 0), /* dat */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 		GPIO_LOOKUP_IDX("mpuio", 11, NULL, 2, 0), /* sel */
^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) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) static struct platform_device nokia770_cbus_device = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	.name   = "i2c-cbus-gpio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	.id     = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) static struct i2c_board_info nokia770_i2c_board_info_2[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		I2C_BOARD_INFO("retu", 0x01),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 		I2C_BOARD_INFO("tahvo", 0x02),
^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) static void __init nokia770_cbus_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	const int retu_irq_gpio = 62;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	const int tahvo_irq_gpio = 40;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	if (gpio_request_one(retu_irq_gpio, GPIOF_IN, "Retu IRQ"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	if (gpio_request_one(tahvo_irq_gpio, GPIOF_IN, "Tahvo IRQ")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 		gpio_free(retu_irq_gpio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	irq_set_irq_type(gpio_to_irq(retu_irq_gpio), IRQ_TYPE_EDGE_RISING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	irq_set_irq_type(gpio_to_irq(tahvo_irq_gpio), IRQ_TYPE_EDGE_RISING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	nokia770_i2c_board_info_2[0].irq = gpio_to_irq(retu_irq_gpio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	nokia770_i2c_board_info_2[1].irq = gpio_to_irq(tahvo_irq_gpio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	i2c_register_board_info(2, nokia770_i2c_board_info_2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 				ARRAY_SIZE(nokia770_i2c_board_info_2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	gpiod_add_lookup_table(&nokia770_cbus_gpio_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	platform_device_register(&nokia770_cbus_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) #else /* CONFIG_I2C_CBUS_GPIO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) static void __init nokia770_cbus_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) #endif /* CONFIG_I2C_CBUS_GPIO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) static void __init omap_nokia770_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	/* On Nokia 770, the SleepX signal is masked with an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	 * MPUIO line by default.  It has to be unmasked for it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	 * to become functional */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	/* SleepX mask direction */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	omap_writew((omap_readw(0xfffb5008) & ~2), 0xfffb5008);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	/* Unmask SleepX signal */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	omap_writew((omap_readw(0xfffb5004) & ~2), 0xfffb5004);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	platform_add_devices(nokia770_devices, ARRAY_SIZE(nokia770_devices));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	nokia770_spi_board_info[1].irq = gpio_to_irq(15);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	spi_register_board_info(nokia770_spi_board_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 				ARRAY_SIZE(nokia770_spi_board_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	omap_serial_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	omap_register_i2c_bus(1, 100, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	hwa742_dev_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	mipid_dev_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	omap1_usb_init(&nokia770_usb_config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	nokia770_mmc_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	nokia770_cbus_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) MACHINE_START(NOKIA770, "Nokia 770")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	.atag_offset	= 0x100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	.map_io		= omap16xx_map_io,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	.init_early     = omap1_init_early,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	.init_irq	= omap1_init_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	.handle_irq	= omap1_handle_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	.init_machine	= omap_nokia770_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	.init_late	= omap1_init_late,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	.init_time	= omap1_timer_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	.restart	= omap1_restart,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) MACHINE_END