linux-ti33x-psp 3.1: ADC support for beaglebone
PATCH v2 1/1 linux-ti33x-psp 3.1: ADC support for beaglebone
First 3 patches are cherry picks from PSP.
Next 7 add support for gen purpose adc, MFD support, sysfs triggering etc.
Currently:
cat /sys/bus/platform/tsc/ain* will trigger sampling Output of the 12-bit ADC will be in decimal 0-4095
TODO:
1. IIO driver support
2. Other ADC features
Signed-off-by Joel A Fernandes <[email protected]>
---
v2 changes:
Direct output to sysfs readers instead of kernel logs
...AM335x-Add-support-for-TSC-on-Beta-GP-EVM.patch | 219 +++++++++ ...M-OMAP-AM335x-Add-support-for-Beta-GP-EVM.patch | 122 +++++ ...d-support-for-pressure-measurement-on-TSC.patch | 219 +++++++++ ...general-purpose-mode-untested-with-touchs.patch | 463 ++++++++++++++++++++ ...dc-Add-board-file-mfd-support-fix-warning.patch | 86 ++++ ...AM335X-init-tsc-bone-style-for-new-boards.patch | 26 ++ ...cadc-make-stepconfig-channel-configurable.patch | 46 ++ .../adc/0008-tscadc-Trigger-through-sysfs.patch | 151 +++++++ ...meta-ti-Remove-debug-messages-for-meta-ti.patch | 34 ++ ...c-switch-to-polling-instead-of-interrupts.patch | 54 +++ recipes-kernel/linux/linux-ti33x-psp_3.1.bb | 12 +- 11 files changed, 1431 insertions(+), 1 deletions(-) create mode 100644 recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0001-AM335x-Add-support-for-TSC-on-Beta-GP-EVM.patch create mode 100644 recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0002-ARM-OMAP-AM335x-Add-support-for-Beta-GP-EVM.patch create mode 100644 recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0003-AM335x-Add-support-for-pressure-measurement-on-TSC.patch create mode 100644 recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0004-tscadc-Add-general-purpose-mode-untested-with-touchs.patch create mode 100644 recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0005-tscadc-Add-board-file-mfd-support-fix-warning.patch create mode 100644 recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0006-AM335X-init-tsc-bone-style-for-new-boards.patch create mode 100644 recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0007-tscadc-make-stepconfig-channel-configurable.patch create mode 100644 recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0008-tscadc-Trigger-through-sysfs.patch create mode 100644 recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0009-meta-ti-Remove-debug-messages-for-meta-ti.patch create mode 100644 recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0010-tscadc-switch-to-polling-instead-of-interrupts.patch
recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0001-AM335x-Add-support-for-TSC-on-Beta-GP-EVM.patch new file +219 -0
@@ -0,0 +1,219 @@ +From 3c22386bee665fb13aeb1f28016a9e77fc6c2dc2 Mon Sep 17 00:00:00 2001 +From: Patil, Rachna <[email protected]> +Date: Fri, 11 Nov 2011 18:03:27 +0530 +Subject: [PATCH 1/9] AM335x: Add support for TSC on Beta GP EVM. + +AN1 and AN2(analog inputs to analog front end) were swapped +on alpha EVM's. This change is IP dependent, hence changes are +made in the driver to support the beta EVM. + +Signed-off-by: Patil, Rachna <[email protected]> +--- + arch/arm/mach-omap2/board-am335xevm.c | 8 +++ + drivers/input/touchscreen/ti_tscadc.c | 83 ++++++++++++++++++++++----------- + include/linux/input/ti_tscadc.h | 10 ++++ + 3 files changed, 73 insertions(+), 28 deletions(-) + +diff --git a/arch/arm/mach-omap2/board-am335xevm.c b/arch/arm/mach-omap2/board-am335xevm.c +index 590c4ca..9ec56c6 100644 +--- a/arch/arm/mach-omap2/board-am335xevm.c ++++ b/arch/arm/mach-omap2/board-am335xevm.c +@@ -912,6 +912,14 @@ static void dvi_init(int evm_id, int profile) + static void tsc_init(int evm_id, int profile) + { + int err; ++ ++ if (gp_evm_revision == GP_EVM_REV_IS_1_1A) { ++ am335x_touchscreen_data.analog_input = 1; ++ pr_info("TSC connected to beta GP EVM\n"); ++ } else { ++ am335x_touchscreen_data.analog_input = 0; ++ pr_info("TSC connected to alpha GP EVM\n"); ++ } + setup_pin_mux(tsc_pin_mux); + err = platform_device_register(&tsc_device); + if (err) +diff --git a/drivers/input/touchscreen/ti_tscadc.c b/drivers/input/touchscreen/ti_tscadc.c +index 1f4db8d..021db7f 100644 +--- a/drivers/input/touchscreen/ti_tscadc.c ++++ b/drivers/input/touchscreen/ti_tscadc.c +@@ -65,13 +65,16 @@ + #define TSCADC_STEPCONFIG_RFP (1 << 12) + #define TSCADC_STEPCONFIG_INM (1 << 18) + #define TSCADC_STEPCONFIG_INP_4 (1 << 19) ++#define TSCADC_STEPCONFIG_INP (1 << 20) + #define TSCADC_STEPCONFIG_INP_5 (1 << 21) + #define TSCADC_STEPCONFIG_FIFO1 (1 << 26) + #define TSCADC_STEPCONFIG_IDLE_INP (1 << 22) + #define TSCADC_STEPCONFIG_OPENDLY 0x018 + #define TSCADC_STEPCONFIG_SAMPLEDLY 0x88 +-#define TSCADC_STEPCHARGE_INM BIT(16) +-#define TSCADC_STEPCHARGE_INP BIT(20) ++#define TSCADC_STEPCHARGE_INM_SWAP BIT(16) ++#define TSCADC_STEPCHARGE_INM BIT(15) ++#define TSCADC_STEPCHARGE_INP_SWAP BIT(20) ++#define TSCADC_STEPCHARGE_INP BIT(19) + #define TSCADC_STEPCHARGE_RFM (1 << 23) + #define TSCADC_STEPCHARGE_DELAY 0x1 + #define TSCADC_CNTRLREG_TSCSSENB BIT(0) +@@ -94,6 +97,7 @@ unsigned int bckup_x = 0, bckup_y = 0; + struct tscadc { + struct input_dev *input; + int wires; ++ int analog_input; + struct clk *clk; + int irq; + void __iomem *tsc_base; +@@ -121,21 +125,37 @@ static void tsc_step_config(struct tscadc *ts_dev) + delay = TSCADC_STEPCONFIG_SAMPLEDLY | TSCADC_STEPCONFIG_OPENDLY; + + stepconfigx = TSCADC_STEPCONFIG_MODE_HWSYNC | +- TSCADC_STEPCONFIG_2SAMPLES_AVG | TSCADC_STEPCONFIG_XPP | +- TSCADC_STEPCONFIG_YPN; ++ TSCADC_STEPCONFIG_2SAMPLES_AVG | TSCADC_STEPCONFIG_XPP; ++ + switch (ts_dev->wires) { + case 4: +- stepconfigx |= TSCADC_STEPCONFIG_INP_4; ++ if (ts_dev->analog_input == 0) ++ stepconfigx |= TSCADC_STEPCONFIG_INP_4 | ++ TSCADC_STEPCONFIG_YPN; ++ else ++ stepconfigx |= TSCADC_STEPCONFIG_INP | ++ TSCADC_STEPCONFIG_XNN; + break; + case 5: +- stepconfigx |= TSCADC_STEPCONFIG_YPP | +- TSCADC_STEPCONFIG_YNN | ++ stepconfigx |= TSCADC_STEPCONFIG_YNN | + TSCADC_STEPCONFIG_INP_5; ++ if (ts_dev->analog_input == 0) ++ stepconfigx |= TSCADC_STEPCONFIG_XNP | ++ TSCADC_STEPCONFIG_YPN; ++ else ++ stepconfigx |= TSCADC_STEPCONFIG_XNN | ++ TSCADC_STEPCONFIG_YPP; + break; + case 8: +- stepconfigx |= TSCADC_STEPCONFIG_INP_4; ++ if (ts_dev->analog_input == 0) ++ stepconfigx |= TSCADC_STEPCONFIG_INP_4 | ++ TSCADC_STEPCONFIG_YPN; ++ else ++ stepconfigx |= TSCADC_STEPCONFIG_INP | ++ TSCADC_STEPCONFIG_XNN; + break; + } ++ + for (i = 1; i < 7; i++) { + tscadc_writel(ts_dev, TSCADC_REG_STEPCONFIG(i), stepconfigx); + tscadc_writel(ts_dev, TSCADC_REG_STEPDELAY(i), delay); +@@ -146,18 +166,28 @@ static void tsc_step_config(struct tscadc *ts_dev) + TSCADC_STEPCONFIG_INM | TSCADC_STEPCONFIG_FIFO1; + switch (ts_dev->wires) { + case 4: +- stepconfigy |= TSCADC_STEPCONFIG_XNP; ++ if (ts_dev->analog_input == 0) ++ stepconfigy |= TSCADC_STEPCONFIG_XNP; ++ else ++ stepconfigy |= TSCADC_STEPCONFIG_YPP; + break; + case 5: +- stepconfigy |= TSCADC_STEPCONFIG_XPP | +- TSCADC_STEPCONFIG_XNP | +- TSCADC_STEPCONFIG_YPN | +- TSCADC_STEPCONFIG_INP_5; ++ stepconfigy |= TSCADC_STEPCONFIG_XPP | TSCADC_STEPCONFIG_INP_5; ++ if (ts_dev->analog_input == 0) ++ stepconfigy |= TSCADC_STEPCONFIG_XNN | ++ TSCADC_STEPCONFIG_YPP; ++ else ++ stepconfigy |= TSCADC_STEPCONFIG_XNP | ++ TSCADC_STEPCONFIG_YPN; + break; + case 8: +- stepconfigy |= TSCADC_STEPCONFIG_XNP; ++ if (ts_dev->analog_input == 0) ++ stepconfigy |= TSCADC_STEPCONFIG_XNP; ++ else ++ stepconfigy |= TSCADC_STEPCONFIG_YPP; + break; + } ++ + for (i = 7; i < 13; i++) { + tscadc_writel(ts_dev, TSCADC_REG_STEPCONFIG(i), stepconfigy); + tscadc_writel(ts_dev, TSCADC_REG_STEPDELAY(i), delay); +@@ -166,8 +196,12 @@ static void tsc_step_config(struct tscadc *ts_dev) + chargeconfig = TSCADC_STEPCONFIG_XPP | + TSCADC_STEPCONFIG_YNN | + TSCADC_STEPCONFIG_RFP | +- TSCADC_STEPCHARGE_INM | TSCADC_STEPCHARGE_INP | + TSCADC_STEPCHARGE_RFM; ++ if (ts_dev->analog_input == 0) ++ chargeconfig |= TSCADC_STEPCHARGE_INM_SWAP | ++ TSCADC_STEPCHARGE_INP_SWAP; ++ else ++ chargeconfig |= TSCADC_STEPCHARGE_INM | TSCADC_STEPCHARGE_INP; + tscadc_writel(ts_dev, TSCADC_REG_CHARGECONFIG, chargeconfig); + tscadc_writel(ts_dev, TSCADC_REG_CHARGEDELAY, TSCADC_STEPCHARGE_DELAY); + +@@ -180,20 +214,12 @@ static void tsc_idle_config(struct tscadc *ts_config) + unsigned int idleconfig; + + idleconfig = TSCADC_STEPCONFIG_YNN | +- TSCADC_STEPCONFIG_XNN | +- TSCADC_STEPCONFIG_INM; ++ TSCADC_STEPCONFIG_INM | TSCADC_STEPCONFIG_IDLE_INP; ++ if (ts_config->analog_input == 0) ++ idleconfig |= TSCADC_STEPCONFIG_XNN; ++ else ++ idleconfig |= TSCADC_STEPCONFIG_YPN; + +- switch (ts_config->wires) { +- case 4: +- idleconfig |= TSCADC_STEPCONFIG_IDLE_INP; +- break; +- case 5: +- idleconfig |= TSCADC_STEPCONFIG_INP_5; +- break; +- case 8: +- idleconfig |= TSCADC_STEPCONFIG_INP_4; +- break; +- } + tscadc_writel(ts_config, TSCADC_REG_IDLECONFIG, idleconfig); + } + +@@ -376,6 +402,7 @@ static int __devinit tscadc_probe(struct platform_device *pdev) + tscadc_writel(ts_dev, TSCADC_REG_IRQWAKEUP, TSCADC_IRQWKUP_ENB); + + ts_dev->wires = pdata->wires; ++ ts_dev->analog_input = pdata->analog_input; + + /* Set the control register bits */ + ctrl = TSCADC_CNTRLREG_STEPCONFIGWRT | +diff --git a/include/linux/input/ti_tscadc.h b/include/linux/input/ti_tscadc.h +index 29f87db..b9d9a46 100644 +--- a/include/linux/input/ti_tscadc.h ++++ b/include/linux/input/ti_tscadc.h +@@ -3,8 +3,18 @@ + * @wires: Wires refer to application modes + * i.e. 4/5/8 wire touchscreen support + * on the platform ++ * @analog_input: Analog inputs refer to the order in which the ++ * connections are made to the AFE. If the connections ++ * are as : XPUL = AN0,XNUR = AN1,YPLL = AN2, ++ * YNLR = AN3, then this variable is set to 1. ++ * Else if the connections are as : ++ * XPUL = AN0,YPLL = AN1,XNUR = AN2, ++ * YNLR = AN3, then set this variable to ++ * 0. + */ + + struct tsc_data { + int wires; ++ int analog_input; ++ + }; +-- +1.7.4.1 +
recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0002-ARM-OMAP-AM335x-Add-support-for-Beta-GP-EVM.patch new file +122 -0
122 lines not on this page · raw message
recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0003-AM335x-Add-support-for-pressure-measurement-on-TSC.patch new file +219 -0
219 lines not on this page · raw message
recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0004-tscadc-Add-general-purpose-mode-untested-with-touchs.patch new file +463 -0
463 lines not on this page · raw message
recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0005-tscadc-Add-board-file-mfd-support-fix-warning.patch new file +86 -0
86 lines not on this page · raw message
recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0006-AM335X-init-tsc-bone-style-for-new-boards.patch new file +26 -0
@@ -0,0 +1,26 @@ +From be48948e9fe62f75cb221309aec0990f9ecd5e01 Mon Sep 17 00:00:00 2001 +From: Joel A Fernandes <[email protected]> +Date: Mon, 28 Nov 2011 18:01:07 -0600 +Subject: [PATCH 6/9] AM335X: init tsc bone style for new boards + +Signed-off-by: Joel A Fernandes <[email protected]> +--- + arch/arm/mach-omap2/board-am335xevm.c | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/arch/arm/mach-omap2/board-am335xevm.c b/arch/arm/mach-omap2/board-am335xevm.c +index 563770e..20b4e29 100644 +--- a/arch/arm/mach-omap2/board-am335xevm.c ++++ b/arch/arm/mach-omap2/board-am335xevm.c +@@ -1554,7 +1554,7 @@ static struct evm_dev_cfg beaglebone_dev_cfg[] = { + {usb1_init, DEV_ON_BASEBOARD, PROFILE_NONE}, + {mmc0_init, DEV_ON_BASEBOARD, PROFILE_NONE}, + {boneleds_init, DEV_ON_BASEBOARD, PROFILE_ALL}, +- {tsc_init, DEV_ON_BASEBOARD, PROFILE_ALL}, ++ {bone_tsc_init, DEV_ON_BASEBOARD, PROFILE_ALL}, + {NULL, 0, 0}, + }; + +-- +1.7.4.1 +
recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0007-tscadc-make-stepconfig-channel-configurable.patch new file +46 -0
46 lines not on this page · raw message
recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0008-tscadc-Trigger-through-sysfs.patch new file +151 -0
151 lines not on this page · raw message
recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0009-meta-ti-Remove-debug-messages-for-meta-ti.patch new file +34 -0
@@ -0,0 +1,34 @@ +From ddb162b6ced5d47caa3a62ab5e95b659287a32d1 Mon Sep 17 00:00:00 2001 +From: Joel A Fernandes <[email protected]> +Date: Mon, 28 Nov 2011 20:56:48 -0600 +Subject: [PATCH 9/9] meta-ti: Remove debug messages for meta-ti + +Signed-off-by: Joel A Fernandes <[email protected]> +--- + drivers/input/touchscreen/ti_tscadc.c | 4 ++-- + 1 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/input/touchscreen/ti_tscadc.c b/drivers/input/touchscreen/ti_tscadc.c +index 0126219..182428b 100644 +--- a/drivers/input/touchscreen/ti_tscadc.c ++++ b/drivers/input/touchscreen/ti_tscadc.c +@@ -181,14 +181,14 @@ static irqreturn_t tsc_adc_interrupt(int irq, void *dev) + + status = tscadc_readl(ts_dev, TSCADC_REG_IRQSTATUS); + +- printk("interrupt! status=%x\n", status); ++ // printk("interrupt! status=%x\n", status); + // if (status & TSCADC_IRQENB_EOS) { + // irqclr |= TSCADC_IRQENB_EOS; + // } + + if (status & TSCADC_IRQENB_FIFO0THRES) { + fifo1count = tscadc_readl(ts_dev, TSCADC_REG_FIFO0CNT); +- printk("fifo 0 count = %d\n", fifo1count); ++ // printk("fifo 0 count = %d\n", fifo1count); + + for (i = 0; i < fifo1count; i++) { + read_sample = tscadc_readl(ts_dev, TSCADC_REG_FIFO0); +-- +1.7.4.1 +
recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0010-tscadc-switch-to-polling-instead-of-interrupts.patch new file +54 -0
54 lines not on this page · raw message
recipes-kernel/linux/linux-ti33x-psp_3.1.bb +11 -1
@@ -11,7 +11,7 @@ MULTI_CONFIG_BASE_SUFFIX = "" BRANCH = "v3.1-meta-ti-r1r+gitr1d84d8853fa30cf3db2571a5aec572accca4e29d" SRCREV = "1d84d8853fa30cf3db2571a5aec572accca4e29d" -MACHINE_KERNEL_PR_append = "c+gitr${SRCREV}" +MACHINE_KERNEL_PR_append = "d+gitr${SRCREV}" COMPATIBLE_MACHINE = "(ti33x)"
@@ -44,6 +44,16 @@ PATCHES_OVER_PSP = " \ file://i2c/0001-arm-omap-mux33xx-Add-i2c2-pin-muix.patch \ file://i2c/0002-omap-hwmod-33xx-Add-support-for-third-i2c-bus.patch \ file://i2c/0003-arm-omap-board-Add-quick-hack-to-get-i2c2-bus-suppor.patch \ + file://adc/0001-AM335x-Add-support-for-TSC-on-Beta-GP-EVM.patch \ + file://adc/0002-ARM-OMAP-AM335x-Add-support-for-Beta-GP-EVM.patch \ + file://adc/0003-AM335x-Add-support-for-pressure-measurement-on-TSC.patch \ + file://adc/0004-tscadc-Add-general-purpose-mode-untested-with-touchs.patch \ + file://adc/0005-tscadc-Add-board-file-mfd-support-fix-warning.patch \ + file://adc/0006-AM335X-init-tsc-bone-style-for-new-boards.patch \ + file://adc/0007-tscadc-make-stepconfig-channel-configurable.patch \ + file://adc/0008-tscadc-Trigger-through-sysfs.patch \ + file://adc/0009-meta-ti-Remove-debug-messages-for-meta-ti.patch \ + file://adc/0010-tscadc-switch-to-polling-instead-of-interrupts.patch \ " SRC_URI += "${@base_contains('DISTRO_FEATURES', 'tipspkernel', "", "${PATCHES_OVER_PSP}", d)}"
Signature · 1 line
1.7.4.1