From cd1f900629246129b96f3fb0699571d010e87487 Mon Sep 17 00:00:00 2001 From: Marcel Ziswiler Date: Sat, 2 Mar 2013 22:39:15 +0100 Subject: apalis/colibri_t20/30: migrate gpio to irq conversion Migrate from static TEGRA_GPIO_TO_IRQ macro to run-time gpio_to_irq function. While at it clean-up some comments and fix some long lines in order to adhere to Linux kernel coding style. --- arch/arm/mach-tegra/board-apalis_t30.c | 38 +++++++++++-------- arch/arm/mach-tegra/board-colibri_t20.c | 67 +++++++++++++++++++++------------ arch/arm/mach-tegra/board-colibri_t30.c | 41 ++++++++++++-------- 3 files changed, 92 insertions(+), 54 deletions(-) diff --git a/arch/arm/mach-tegra/board-apalis_t30.c b/arch/arm/mach-tegra/board-apalis_t30.c index f34e68d891f1..5103c3ca2f4a 100644 --- a/arch/arm/mach-tegra/board-apalis_t30.c +++ b/arch/arm/mach-tegra/board-apalis_t30.c @@ -254,7 +254,8 @@ static struct stmpe_ts_platform_data stmpe811_ts_data = { .adc_freq = 1, /* 3.25 MHz ADC clock speed */ .ave_ctrl = 3, /* 8 sample average control */ .fraction_z = 7, /* 7 length fractional part in z */ - .i_drive = 1, /* 50 mA typical 80 mA max touchscreen drivers current limit value */ + .i_drive = 1, /* 50 mA typical 80 mA max touchscreen + drivers current limit value */ .mod_12b = 1, /* 12-bit ADC */ .ref_sel = 0, /* internal ADC reference */ .sample_time = 4, /* ADC converstion time: 80 clocks */ @@ -286,7 +287,6 @@ static struct i2c_board_info apalis_t30_i2c_bus5_board_info[] __initdata = { /* STMPE811 touch screen controller */ I2C_BOARD_INFO("stmpe", 0x41), .flags = I2C_CLIENT_WAKE, - .irq = TEGRA_GPIO_TO_IRQ(TOUCH_PEN_INT), .platform_data = &stmpe811_data, .type = "stmpe811", }, @@ -319,13 +319,16 @@ static void __init apalis_t30_i2c_init(void) platform_device_register(&tegra_i2c_device4); platform_device_register(&tegra_i2c_device5); - i2c_register_board_info(0, apalis_t30_i2c_bus1_board_info, ARRAY_SIZE(apalis_t30_i2c_bus1_board_info)); + i2c_register_board_info(0, apalis_t30_i2c_bus1_board_info, + ARRAY_SIZE(apalis_t30_i2c_bus1_board_info)); /* enable touch interrupt GPIO */ gpio_request(TOUCH_PEN_INT, "TOUCH_PEN_INT"); gpio_direction_input(TOUCH_PEN_INT); - i2c_register_board_info(4, apalis_t30_i2c_bus5_board_info, ARRAY_SIZE(apalis_t30_i2c_bus5_board_info)); + apalis_t30_i2c_bus5_board_info[1].irq = gpio_to_irq(TOUCH_PEN_INT); + i2c_register_board_info(4, apalis_t30_i2c_bus5_board_info, + ARRAY_SIZE(apalis_t30_i2c_bus5_board_info)); } /* IrDA */ @@ -351,8 +354,6 @@ static struct tegra_sdhci_platform_data apalis_t30_emmc_platform_data = { }; static struct tegra_sdhci_platform_data apalis_t30_mmccard_platform_data = { -//GPIO tested with GPIOConfig but interrupt not working -//even 8-bit cards work if plugged during boot .cd_gpio = MMC1_CD_N, .ddr_clk_limit = 52000000, .is_8bit = 1, @@ -701,7 +702,8 @@ static void thermd_alert_work_func(struct work_struct *work) if (!apalis_t30_low_edge && temp <= apalis_t30_low_limit) { apalis_t30_alert_func(apalis_t30_alert_data); apalis_t30_low_edge = 1; - } else if (apalis_t30_low_edge && temp > apalis_t30_low_limit + apalis_t30_low_hysteresis) { + } else if (apalis_t30_low_edge && temp > apalis_t30_low_limit + + apalis_t30_low_hysteresis) { apalis_t30_low_edge = 0; } @@ -709,7 +711,7 @@ static void thermd_alert_work_func(struct work_struct *work) if (thermd_alert_irq_disabled) { apalis_t30_alert_func(apalis_t30_alert_data); thermd_alert_irq_disabled = 0; - enable_irq(TEGRA_GPIO_TO_IRQ(THERMD_ALERT_N)); + enable_irq(gpio_to_irq(THERMD_ALERT_N)); } /* Keep re-scheduling */ @@ -741,7 +743,8 @@ static int lm95245_set_limits(void *_data, { struct device *lm95245_device = _data; apalis_t30_low_limit = lo_limit_milli; - if (lm95245_device) lm95245_set_remote_os_limit(lm95245_device, hi_limit_milli); + if (lm95245_device) lm95245_set_remote_os_limit(lm95245_device, + hi_limit_milli); return 0; } @@ -758,7 +761,8 @@ static int lm95245_set_alert(void *_data, static int lm95245_set_shutdown_temp(void *_data, long shutdown_temp) { struct device *lm95245_device = _data; - if (lm95245_device) lm95245_set_remote_critical_limit(lm95245_device, shutdown_temp); + if (lm95245_device) lm95245_set_remote_critical_limit(lm95245_device, + shutdown_temp); return 0; } @@ -817,9 +821,10 @@ static void lm95245_probe_callback(struct device *dev) } #endif /* CONFIG_TEGRA_SKIN_THROTTLE */ - if (request_irq(TEGRA_GPIO_TO_IRQ(THERMD_ALERT_N), thermd_alert_irq, + if (request_irq(gpio_to_irq(THERMD_ALERT_N), thermd_alert_irq, IRQF_TRIGGER_LOW, "THERMD_ALERT_N", NULL)) - pr_err("%s: unable to register THERMD_ALERT_N interrupt\n", __func__); + pr_err("%s: unable to register THERMD_ALERT_N interrupt\n", + __func__); } static void apalis_t30_thermd_alert_init(void) @@ -827,7 +832,8 @@ static void apalis_t30_thermd_alert_init(void) gpio_request(THERMD_ALERT_N, "THERMD_ALERT_N"); gpio_direction_input(THERMD_ALERT_N); - thermd_alert_workqueue = create_singlethread_workqueue("THERMD_ALERT_N"); + thermd_alert_workqueue = create_singlethread_workqueue("THERMD_ALERT_N" + ); INIT_WORK(&thermd_alert_work, thermd_alert_work_func); } @@ -898,7 +904,8 @@ static void __init uart_debug_init(void) break; default: - pr_info("The debug console id %d is invalid, Assuming UARTA", debug_port_id); + pr_info("The debug console id %d is invalid, Assuming UARTA", + debug_port_id); apalis_t30_uart_devices[0] = &debug_uarta_device; debug_uart_clk = clk_get_sys("serial8250.0", "uarta"); debug_uart_port_base = ((struct plat_serial8250_port *)( @@ -1180,7 +1187,8 @@ static void __init apalis_t30_init(void) #ifdef CONFIG_W1_MASTER_TEGRA tegra_w1_device.dev.platform_data = &apalis_t30_w1_platform_data; #endif - platform_add_devices(apalis_t30_devices, ARRAY_SIZE(apalis_t30_devices)); + platform_add_devices(apalis_t30_devices, ARRAY_SIZE(apalis_t30_devices) + ); tegra_ram_console_debug_init(); tegra_io_dpd_init(); apalis_t30_sdhci_init(); diff --git a/arch/arm/mach-tegra/board-colibri_t20.c b/arch/arm/mach-tegra/board-colibri_t20.c index edf1e72d3cc1..c752e2cd583d 100644 --- a/arch/arm/mach-tegra/board-colibri_t20.c +++ b/arch/arm/mach-tegra/board-colibri_t20.c @@ -92,7 +92,8 @@ static struct tegra_clk_init_table colibri_t20_clk_init_table[] __initdata = { {"pwm", "clk_m", 0, false}, {"spdif_out", "pll_a_out0", 0, false}, -//required otherwise getting disabled by "Disabling clocks left on by bootloader" stage +//required otherwise getting disabled by "Disabling clocks left on by +//bootloader" stage {"uarta", "pll_p", 216000000, true}, //required otherwise uses pll_p_out4 as parent and changing its rate to 72 MHz @@ -111,7 +112,8 @@ static struct tegra_clk_init_table colibri_t20_clk_init_table[] __initdata = { {"ndflash", "pll_p", 108000000, false}, //[ 2.284308] kernel BUG at drivers/spi/spi-tegra.c:254! -//[ 2.289454] Unable to handle kernel NULL pointer dereference at virtual address 00000000 +//[ 2.289454] Unable to handle kernel NULL pointer dereference at virtual +// address 00000000 {"sbc4", "pll_p", 12000000, false}, {NULL, NULL, 0, 0}, @@ -153,7 +155,8 @@ static struct tegra_clk_init_table colibri_t20_clk_init_table[] __initdata = { #define USBH_PEN TEGRA_GPIO_PW2 /* SODIMM 129 */ static struct gpio colibri_t20_gpios[] = { -//conflicts with CAN interrupt on Colibri Evaluation Board and MECS Tellurium xPOD1 CAN +//conflicts with CAN interrupt on Colibri Evaluation Board and MECS Tellurium +//xPOD1 CAN //conflicts with DAC_PSAVE# on Iris #ifndef IRIS {TEGRA_GPIO_PA0, GPIOF_IN, "SODIMM pin 73"}, @@ -399,8 +402,10 @@ static void colibri_t20_i2c_init(void) } /* Keys - Note: active-low means pull-ups required on carrier board resp. via pin-muxing - Note2: power-key active-high due to EvalBoard v3.1a having 100 K pull-down on SODIMM pin 45 */ + Note: active-low means pull-ups required on carrier board resp. via + pin-muxing + Note2: power-key active-high due to EvalBoard v3.1a having 100 K pull-down + on SODIMM pin 45 */ #ifdef CONFIG_KEYBOARD_GPIO #define GPIO_KEY(_id, _gpio, _lowactive, _iswake) \ @@ -417,10 +422,12 @@ static void colibri_t20_i2c_init(void) static struct gpio_keys_button colibri_t20_keys[] = { [0] = GPIO_KEY(KEY_FIND, PT3, 1, 0), /* SODIMM pin 77 */ [1] = GPIO_KEY(KEY_HOME, PBB3, 1, 0), /* SODIMM pin 127 */ - [2] = GPIO_KEY(KEY_BACK, PBB2, 1, 0), /* SODIMM pin 133, Iris X16-14 */ + [2] = GPIO_KEY(KEY_BACK, PBB2, 1, 0), /* SODIMM pin 133, + Iris X16-14 */ [3] = GPIO_KEY(KEY_VOLUMEUP, PBB4, 1, 0), /* SODIMM pin 22 */ [4] = GPIO_KEY(KEY_VOLUMEDOWN, PBB5, 1, 0), /* SODIMM pin 24 */ - [5] = GPIO_KEY(KEY_POWER, PV3, 0, 1), /* SODIMM pin 45, Iris X16-20 */ + [5] = GPIO_KEY(KEY_POWER, PV3, 0, 1), /* SODIMM pin 45, + Iris X16-20 */ [6] = GPIO_KEY(KEY_MENU, PK6, 1, 0), /* SODIMM pin 135 */ }; @@ -579,12 +586,13 @@ static struct tegra_nand_chip_parms nand_chip_parms[] = { .capacity = 1024, .timing = { .trp = 12, /* tRP, ND_nRE pulse width */ - .trh = 100, /* tRHZ, ND_nRE high duration */ + .trh = 100, /* tRHZ, ND_nRE high + duration */ .twp = 12, /* tWP, ND_nWE pulse time */ .twh = 10, /* tWH, ND_nWE high duration */ .tcs = 20, /* Max(tCS, tCH, tALS, tALH) */ - .twhr = 60, /* tWHR, ND_nWE high to ND_nRE low delay for - status read */ + .twhr = 60, /* tWHR, ND_nWE high to ND_nRE + low delay for status read */ .tcr_tar_trr = 20, /* Max(tCR, tAR, tRR) */ .twb = 100, .trp_resp = 12, /* tRP */ @@ -691,7 +699,7 @@ static struct platform_device tegra_rtc_device = { #if defined(CONFIG_SPI_TEGRA) && defined(CONFIG_SPI_SPIDEV) static struct spi_board_info tegra_spi_devices[] __initdata = { { - .bus_num = 3, /* SPI4 */ + .bus_num = 3, /* SPI4: Colibri SSP */ .chip_select = 0, .irq = 0, .max_speed_hz = 50000000, @@ -748,11 +756,13 @@ static void thermd_alert_work_func(struct work_struct *work) pr_err("over-temperature condition %d degC reached, initiating " "immediate shutdown", temp); kernel_power_off(); - } else if (temp < colibri_t20_throttle_temp - colibri_t20_throttle_hysteresis) { + } else if (temp < colibri_t20_throttle_temp - + colibri_t20_throttle_hysteresis) { /* Make sure throttling gets disabled again */ if (tegra_is_throttling()) { tegra_throttling_enable(false); - lm95245_set_remote_os_limit(lm95245_device, colibri_t20_throttle_temp); + lm95245_set_remote_os_limit(lm95245_device, + colibri_t20_throttle_temp); } } else if (temp < colibri_t20_throttle_temp) { /* Operating within hysteresis so keep re-scheduling to catch @@ -765,7 +775,8 @@ static void thermd_alert_work_func(struct work_struct *work) /* Make sure throttling gets enabled and set shutdown limit */ if (!tegra_is_throttling()) { tegra_throttling_enable(true); - lm95245_set_remote_os_limit(lm95245_device, colibri_t20_shutdown_temp); + lm95245_set_remote_os_limit(lm95245_device, + colibri_t20_shutdown_temp); } /* And re-schedule again */ msleep(100); @@ -775,7 +786,7 @@ static void thermd_alert_work_func(struct work_struct *work) /* Avoid unbalanced enable for IRQ 367 */ if (thermd_alert_irq_disabled) { thermd_alert_irq_disabled = 0; - enable_irq(TEGRA_GPIO_TO_IRQ(THERMD_ALERT)); + enable_irq(gpio_to_irq(THERMD_ALERT)); } } @@ -795,9 +806,10 @@ static void lm95245_probe_callback(struct device *dev) lm95245_set_remote_os_limit(lm95245_device, colibri_t20_throttle_temp); - if (request_irq(TEGRA_GPIO_TO_IRQ(THERMD_ALERT), thermd_alert_irq, + if (request_irq(gpio_to_irq(THERMD_ALERT), thermd_alert_irq, IRQF_TRIGGER_LOW, "THERMD_ALERT", NULL)) - pr_err("%s: unable to register THERMD_ALERT interrupt\n", __func__); + pr_err("%s: unable to register THERMD_ALERT interrupt\n", + __func__); } #ifdef CONFIG_DEBUG_FS @@ -811,7 +823,8 @@ static int colibri_t20_thermal_set_throttle_temp(void *data, u64 val) { colibri_t20_throttle_temp = val; if (!tegra_is_throttling() && lm95245_device) - lm95245_set_remote_os_limit(lm95245_device, colibri_t20_throttle_temp); + lm95245_set_remote_os_limit(lm95245_device, + colibri_t20_throttle_temp); return 0; } @@ -831,12 +844,14 @@ static int colibri_t20_thermal_set_shutdown_temp(void *data, u64 val) { colibri_t20_shutdown_temp = val; if (tegra_is_throttling() && lm95245_device) - lm95245_set_remote_os_limit(lm95245_device, colibri_t20_shutdown_temp); + lm95245_set_remote_os_limit(lm95245_device, + colibri_t20_shutdown_temp); /* Carefull as we can only actively monitor one temperatur limit and assumption is throttling is lower than shutdown one. */ if (colibri_t20_shutdown_temp < colibri_t20_throttle_temp) - colibri_t20_thermal_set_throttle_temp(NULL, colibri_t20_shutdown_temp); + colibri_t20_thermal_set_throttle_temp(NULL, + colibri_t20_shutdown_temp); return 0; } @@ -1190,13 +1205,17 @@ static void colibri_t20_usb_init(void) printk("MECS Tellurium USB Hub Initialisation\n"); - /* configure USB hub reset line as output and pull low into reset */ - gpio_status = gpio_request(tellurium_usb_hub_reset, "USB_HUB_RESET"); + /* configure USB hub reset line as output and pull low into + reset */ + gpio_status = gpio_request(tellurium_usb_hub_reset, + "USB_HUB_RESET"); if (gpio_status < 0) pr_warning("USB_HUB_RESET request GPIO FAILED\n"); - gpio_status = gpio_direction_output(tellurium_usb_hub_reset, 0); + gpio_status = gpio_direction_output(tellurium_usb_hub_reset, + 0); if (gpio_status < 0) - pr_warning("USB_HUB_RESET request GPIO DIRECTION FAILED\n"); + pr_warning("USB_HUB_RESET request GPIO DIRECTION " + "FAILED\n"); /* configure I2C pins as outputs and pull low */ gpio_status = gpio_direction_output(i2c_scl, 0); diff --git a/arch/arm/mach-tegra/board-colibri_t30.c b/arch/arm/mach-tegra/board-colibri_t30.c index fe1bd83afd99..29fb0a607fd5 100644 --- a/arch/arm/mach-tegra/board-colibri_t30.c +++ b/arch/arm/mach-tegra/board-colibri_t30.c @@ -56,7 +56,8 @@ static struct tegra_asoc_platform_data colibri_t30_audio_sgtl5000_pdata = { .gpio_int_mic_en = -1, .gpio_ext_mic_en = -1, .i2s_param[HIFI_CODEC] = { - .audio_port_id = 0, + .audio_port_id = 0, /* index of below registered + tegra_i2s_device */ .i2s_mode = TEGRA_DAIFMT_I2S, .is_i2s_master = 1, .sample_size = 16, @@ -210,7 +211,8 @@ static struct stmpe_ts_platform_data stmpe811_ts_data = { .adc_freq = 1, /* 3.25 MHz ADC clock speed */ .ave_ctrl = 3, /* 8 sample average control */ .fraction_z = 7, /* 7 length fractional part in z */ - .i_drive = 1, /* 50 mA typical 80 mA max touchscreen drivers current limit value */ + .i_drive = 1, /* 50 mA typical 80 mA max touchscreen + drivers current limit value */ .mod_12b = 1, /* 12-bit ADC */ .ref_sel = 0, /* internal ADC reference */ .sample_time = 4, /* ADC converstion time: 80 clocks */ @@ -242,7 +244,6 @@ static struct i2c_board_info colibri_t30_i2c_bus5_board_info[] __initdata = { /* STMPE811 touch screen controller */ I2C_BOARD_INFO("stmpe", 0x41), .flags = I2C_CLIENT_WAKE, - .irq = TEGRA_GPIO_TO_IRQ(TOUCH_PEN_INT), .platform_data = &stmpe811_data, .type = "stmpe811", }, @@ -302,13 +303,16 @@ static void __init colibri_t30_i2c_init(void) gpio_request(TOUCH_PEN_INT, "TOUCH_PEN_INT"); gpio_direction_input(TOUCH_PEN_INT); + colibri_t30_i2c_bus5_board_info[1].irq = gpio_to_irq(TOUCH_PEN_INT); i2c_register_board_info(4, colibri_t30_i2c_bus5_board_info, ARRAY_SIZE(colibri_t30_i2c_bus5_board_info)); } /* Keys - Note: active-low means pull-ups required on carrier board resp. via pin-muxing - Note2: power-key active-high due to EvalBoard v3.1a having 100 K pull-down on SODIMM pin 45 */ + Note: active-low means pull-ups required on carrier board resp. via + pin-muxing + Note2: power-key active-high due to EvalBoard v3.1a having 100 K pull-down + on SODIMM pin 45 */ #ifdef CONFIG_KEYBOARD_GPIO #define GPIO_KEY(_id, _gpio, _lowactive, _iswake) \ @@ -327,10 +331,12 @@ static struct gpio_keys_button colibri_t30_keys[] = { GPIO_KEY(KEY_FIND, PCC2, 1, 0), /* SODIMM pin 77 */ #endif GPIO_KEY(KEY_HOME, PT6, 1, 0), /* SODIMM pin 127 */ - GPIO_KEY(KEY_BACK, PT5, 1, 1), /* SODIMM pin 133, Iris X16-14 */ + GPIO_KEY(KEY_BACK, PT5, 1, 1), /* SODIMM pin 133, + Iris X16-14 */ GPIO_KEY(KEY_VOLUMEUP, PDD7, 1, 0), /* SODIMM pin 22 */ GPIO_KEY(KEY_VOLUMEDOWN, PCC6, 1, 0), /* SODIMM pin 24 */ - GPIO_KEY(KEY_POWER, PV1, 0, 1), /* SODIMM pin 45, Iris X16-20 */ + GPIO_KEY(KEY_POWER, PV1, 0, 1), /* SODIMM pin 45, + Iris X16-20 */ GPIO_KEY(KEY_MENU, PK6, 1, 0), /* SODIMM pin 135 */ }; @@ -454,7 +460,7 @@ static struct platform_device tegra_rtc_device = { #if defined(CONFIG_SPI_TEGRA) && defined(CONFIG_SPI_SPIDEV) static struct spi_board_info tegra_spi_devices[] __initdata = { { - .bus_num = 0, /* SPI1 */ + .bus_num = 0, /* SPI1: Colibri SSP */ .chip_select = 0, .irq = 0, .max_speed_hz = 50000000, @@ -637,7 +643,8 @@ static void thermd_alert_work_func(struct work_struct *work) if (!colibri_t30_low_edge && temp <= colibri_t30_low_limit) { colibri_t30_alert_func(colibri_t30_alert_data); colibri_t30_low_edge = 1; - } else if (colibri_t30_low_edge && temp > colibri_t30_low_limit + colibri_t30_low_hysteresis) { + } else if (colibri_t30_low_edge && temp > colibri_t30_low_limit + + colibri_t30_low_hysteresis) { colibri_t30_low_edge = 0; } @@ -645,7 +652,7 @@ static void thermd_alert_work_func(struct work_struct *work) if (thermd_alert_irq_disabled) { colibri_t30_alert_func(colibri_t30_alert_data); thermd_alert_irq_disabled = 0; - enable_irq(TEGRA_GPIO_TO_IRQ(THERMD_ALERT)); + enable_irq(gpio_to_irq(THERMD_ALERT)); } /* Keep re-scheduling */ @@ -677,7 +684,8 @@ static int lm95245_set_limits(void *_data, { struct device *lm95245_device = _data; colibri_t30_low_limit = lo_limit_milli; - if (lm95245_device) lm95245_set_remote_os_limit(lm95245_device, hi_limit_milli); + if (lm95245_device) lm95245_set_remote_os_limit(lm95245_device, + hi_limit_milli); return 0; } @@ -694,7 +702,8 @@ static int lm95245_set_alert(void *_data, static int lm95245_set_shutdown_temp(void *_data, long shutdown_temp) { struct device *lm95245_device = _data; - if (lm95245_device) lm95245_set_remote_critical_limit(lm95245_device, shutdown_temp); + if (lm95245_device) lm95245_set_remote_critical_limit(lm95245_device, + shutdown_temp); return 0; } @@ -753,9 +762,10 @@ static void lm95245_probe_callback(struct device *dev) } #endif /* CONFIG_TEGRA_SKIN_THROTTLE */ - if (request_irq(TEGRA_GPIO_TO_IRQ(THERMD_ALERT), thermd_alert_irq, + if (request_irq(gpio_to_irq(THERMD_ALERT), thermd_alert_irq, IRQF_TRIGGER_LOW, "THERMD_ALERT", NULL)) - pr_err("%s: unable to register THERMD_ALERT interrupt\n", __func__); + pr_err("%s: unable to register THERMD_ALERT interrupt\n", + __func__); } static void colibri_t30_thermd_alert_init(void) @@ -824,7 +834,8 @@ static void __init uart_debug_init(void) break; default: - pr_info("The debug console id %d is invalid, Assuming UARTA", debug_port_id); + pr_info("The debug console id %d is invalid, Assuming UARTA", + debug_port_id); colibri_t30_uart_devices[0] = &debug_uarta_device; debug_uart_clk = clk_get_sys("serial8250.0", "uarta"); debug_uart_port_base = ((struct plat_serial8250_port *)( -- cgit v1.2.3