Commit 778ea778 authored by Alexey Mednyy's avatar Alexey Mednyy 🆖

add mc34708 touchscreen

new imx53-shm order
parent d1b5b5e7
......@@ -275,7 +275,8 @@ dtb-$(CONFIG_SOC_IMX53) += \
imx53-mba53.dtb \
imx53-qsb.dtb \
imx53-qsrb.dtb \
imx53-shm.dtb \
imx53-shm-minipos.dtb \
imx53-shm-t2m-ls.dtb \
imx53-smd.dtb \
imx53-tx53-x03x.dtb \
imx53-tx53-x13x.dtb \
......
......@@ -9,7 +9,6 @@
* http://www.opensource.org/licenses/gpl-license.html
* http://www.gnu.org/copyleft/gpl.html
*/
#include "imx53.dtsi"
#include <dt-bindings/pwm/pwm.h>
......@@ -279,46 +278,6 @@
>;
};
// pinctrl_ipu_disp0: ipudisp0grp {
// fsl,pins = <
// // MX53_PAD_DI0_DISP_CLK__IPU_DI0_DISP_CLK 0x5
// // MX53_PAD_DI0_PIN15__IPU_DI0_PIN15 0x5
// // MX53_PAD_DI0_PIN2__IPU_DI0_PIN2 0x5
// // MX53_PAD_DI0_PIN3__IPU_DI0_PIN3 0x5
// // MX53_PAD_DISP0_DAT0__IPU_DISP0_DAT_0 0x5
// // MX53_PAD_DISP0_DAT1__IPU_DISP0_DAT_1 0x5
// // MX53_PAD_DISP0_DAT2__IPU_DISP0_DAT_2 0x5
// // MX53_PAD_DISP0_DAT3__IPU_DISP0_DAT_3 0x5
// // MX53_PAD_DISP0_DAT4__IPU_DISP0_DAT_4 0x5
// // MX53_PAD_DISP0_DAT5__IPU_DISP0_DAT_5 0x5
// // MX53_PAD_DISP0_DAT6__IPU_DISP0_DAT_6 0x5
// // MX53_PAD_DISP0_DAT7__IPU_DISP0_DAT_7 0x5
// // MX53_PAD_DISP0_DAT8__IPU_DISP0_DAT_8 0x5
// // MX53_PAD_DISP0_DAT9__IPU_DISP0_DAT_9 0x5
// // MX53_PAD_DISP0_DAT10__IPU_DISP0_DAT_10 0x5
// // MX53_PAD_DISP0_DAT11__IPU_DISP0_DAT_11 0x5
// // MX53_PAD_DISP0_DAT12__IPU_DISP0_DAT_12 0x5
// // MX53_PAD_DISP0_DAT13__IPU_DISP0_DAT_13 0x5
// // MX53_PAD_DISP0_DAT14__IPU_DISP0_DAT_14 0x5
// // MX53_PAD_DISP0_DAT15__IPU_DISP0_DAT_15 0x5
// // MX53_PAD_DISP0_DAT16__IPU_DISP0_DAT_16 0x5
// // MX53_PAD_DISP0_DAT17__IPU_DISP0_DAT_17 0x5
// // MX53_PAD_DISP0_DAT18__IPU_DISP0_DAT_18 0x5
// // MX53_PAD_DISP0_DAT19__IPU_DISP0_DAT_19 0x5
// // MX53_PAD_DISP0_DAT20__IPU_DISP0_DAT_20 0x5
// // MX53_PAD_DISP0_DAT21__IPU_DISP0_DAT_21 0x5
// // MX53_PAD_DISP0_DAT22__IPU_DISP0_DAT_22 0x5
// // MX53_PAD_DISP0_DAT23__IPU_DISP0_DAT_23 0x5
// >;
// };
// pinctrl_vga_sync: vgasync-grp {
// fsl,pins = <
// /* VGA_HSYNC, VSYNC with max drive strength */
// MX53_PAD_EIM_OE__IPU_DI1_PIN7 0xe6
// MX53_PAD_EIM_RW__IPU_DI1_PIN8 0xe6
// >;
// };
pinctrl_uart1: uart1grp {
fsl,pins = <
......@@ -505,6 +464,137 @@
// };
&i2c1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_i2c1>;
status = "okay";
pmic: mc34708@8 {
compatible = "fsl,mc34708";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_pmic>;
fsl,mc13xxx-uses-rtc;
fsl,mc13xxx-uses-touch;
fsl,mc13xxx-uses-adc;
reg = <0x08>;
interrupt-parent = <&gpio5>;
interrupts = <28 4>;
regulators {
sw1_reg: sw1a {
regulator-name = "SW1";
regulator-min-microvolt = <650000>;
regulator-max-microvolt = <1437500>;
regulator-boot-on;
regulator-always-on;
};
sw1b_reg: sw1b {
regulator-name = "SW1B";
regulator-min-microvolt = <650000>;
regulator-max-microvolt = <1437500>;
regulator-boot-on;
regulator-always-on;
};
sw2_reg: sw2 {
regulator-name = "SW2";
regulator-min-microvolt = <650000>;
regulator-max-microvolt = <1437500>;
regulator-boot-on;
regulator-always-on;
};
sw3_reg: sw3 {
regulator-name = "SW3";
regulator-min-microvolt = <650000>;
regulator-max-microvolt = <1425000>;
regulator-boot-on;
};
sw4a_reg: sw4a {
regulator-name = "SW4A";
regulator-min-microvolt = <1200000>;
regulator-max-microvolt = <3300000>;
regulator-boot-on;
regulator-always-on;
};
sw4b_reg: sw4b {
regulator-name = "SW4B";
regulator-min-microvolt = <1200000>;
regulator-max-microvolt = <3300000>;
regulator-boot-on;
regulator-always-on;
};
sw5_reg: sw5 {
regulator-name = "SW5";
regulator-min-microvolt = <1200000>;
regulator-max-microvolt = <1975000>;
regulator-boot-on;
regulator-always-on;
};
swbst_reg: swbst {
regulator-name = "SWBST";
regulator-boot-on;
regulator-always-on;
};
vpll_reg: vpll {
regulator-name = "VPLL";
regulator-min-microvolt = <1200000>;
regulator-max-microvolt = <1800000>;
regulator-boot-on;
};
vrefddr_reg: vrefddr {
regulator-name = "VREFDDR";
regulator-boot-on;
regulator-always-on;
};
vusb_reg: vusb {
regulator-name = "VUSB";
regulator-boot-on;
regulator-always-on;
};
vusb2_reg: vusb2 {
regulator-name = "VUSB2";
regulator-min-microvolt = <2500000>;
regulator-max-microvolt = <3000000>;
regulator-boot-on;
regulator-always-on;
};
vdac_reg: vdac {
regulator-name = "VDAC";
regulator-min-microvolt = <2500000>;
regulator-max-microvolt = <2775000>;
regulator-boot-on;
regulator-always-on;
};
vgen1_reg: vgen1 {
regulator-name = "VGEN1";
regulator-min-microvolt = <1200000>;
regulator-max-microvolt = <1550000>;
regulator-boot-on;
regulator-always-on;
};
vgen2_reg: vgen2 {
regulator-name = "VGEN2";
regulator-min-microvolt = <2500000>;
regulator-max-microvolt = <3300000>;
regulator-boot-on;
regulator-always-on;
};
};
};
};
&vpu {
status = "okay";
};
......@@ -518,4 +608,4 @@
&usbotg {
dr_mode = "peripheral";
status = "okay";
};
\ No newline at end of file
};
......@@ -11,7 +11,8 @@
*/
/dts-v1/;
memgpu: /memreserve/ 0xb0000000 0x04000000;
/* memgpu: /memreserve/ 0xb0000000 0x04000000; */
memgpu: /memreserve/ 0x80000000 0x4000000;
#include "imx53-shm-common.dtsi"
......@@ -40,6 +41,11 @@ memgpu: /memreserve/ 0xb0000000 0x04000000;
};
};
&gpu {
mem = <0x80000000 0x4000000>;
};
&iomuxc {
i2c2 {
pinctrl_pmic: pmicgrp {
......
/*
* Copyright 2011 Freescale Semiconductor, Inc.
* Copyright 2011 Linaro Ltd.
*
* The code contained herein is licensed under the GNU General Public
* License. You may obtain a copy of the GNU General Public License
* Version 2 or later at the following locations:
*
* http://www.opensource.org/licenses/gpl-license.html
* http://www.gnu.org/copyleft/gpl.html
*/
/dts-v1/;
/* memgpu: /memreserve/ 0xb0000000 0x04000000; */
// memgpu: /memreserve/ 0x80000000 0x4000000;
#include "imx53-shm-common.dtsi"
/ {
model = "Freescale i.MX53 SHM-DV7LS";
compatible = "fsl,imx53-qsrb", "fsl,imx53";
backlight0: backlight0 {
compatible = "pwm-backlight";
pwms = <&pwm2 0 500000 0>;
brightness-levels = <
0 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19
20 21 22 23 24 25 26 27 28 29
30 31 32 33 34 35 36 37 38 39
40 41 42 43 44 45 46 47 48 49
50 51 52 53 54 55 56 57 58 59
60 61 62 63 64 65 66 67 68 69
70 71 72 73 74 75 76 77 78 79
80 81 82 83 84 85 86 87 88 89
90 91 92 93 94 95 96 97 98 99
100
>;
default-brightness-level = <50>;
};
};
// &gpu {
// mem = <0x80000000 0x4000000>;
// };
&iomuxc {
i2c2 {
pinctrl_pmic: pmicgrp {
fsl,pins = <
MX53_PAD_CSI0_DAT10__GPIO5_28 0x100 /* IRQ */
>;
};
};
pinctrl_uart5: uart5grp {
fsl,pins = <
MX53_PAD_CSI0_DAT15__UART5_RXD_MUX 0x1e4
MX53_PAD_CSI0_DAT14__UART5_TXD_MUX 0x1e4
>;
};
};
&uart5 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_uart5>;
status = "okay";
};
......@@ -172,6 +172,19 @@
};
};
gpu: gpu@20000000 { /* AMD Z160, Z340 */
compatible = "fsl,imx53-gpu";
reg = <0x20000000 0x10000000
0x30000000 0x10000000
0xf8020000 0x40000>;
reg-names = "gpu_2d_registers", "gpu_3d_registers",
"gpu_graphics_mem";
interrupts = <84 12>;
interrupt-names = "gpu_2d_irq", "gpu_3d_irq";
clocks = <&clks 162>, <&clks 163>, <&clks 164>;
clock-names = "3d", "2d", "garb";
};
aips@50000000 { /* AIPS1 */
compatible = "fsl,aips-bus", "simple-bus";
#address-cells = <1>;
......
......@@ -33,6 +33,8 @@ MODULE_PARM_DESC(sample_tolerance,
"is supposed to be wrong and is discarded. Set to 0 to "
"disable this check.");
struct mc13xxx_driver_data;
struct mc13783_ts_priv {
struct input_dev *idev;
struct mc13xxx *mc13xxx;
......@@ -41,6 +43,50 @@ struct mc13783_ts_priv {
unsigned int sample[4];
u8 ato;
bool atox;
struct mc13xxx_driver_data *drvdata;
};
enum mc13xxx_type {
MC13XXX_TYPE_MC13783,
MC13XXX_TYPE_MC34708,
};
struct mc13xxx_driver_data {
int (*set_pen_detection)(struct mc13783_ts_priv *, bool enable);
enum mc13xxx_type type;
};
static int mc13783_set_pen_detection(struct mc13783_ts_priv *priv, bool enable)
{
if (enable)
return mc13xxx_reg_rmw(priv->mc13xxx, MC13XXX_ADC0,
MC13XXX_ADC0_TSMOD_MASK, MC13XXX_ADC0_TSMOD0);
else
return mc13xxx_reg_rmw(priv->mc13xxx, MC13XXX_ADC0,
MC13XXX_ADC0_TSMOD_MASK, 0);
}
#define MC34708_ADC0_TSPENDETEN (1 << 20)
static int mc34708_set_pen_detection(struct mc13783_ts_priv *priv, bool enable)
{
if (enable)
return mc13xxx_reg_rmw(priv->mc13xxx, MC13XXX_ADC0,
MC34708_ADC0_TSPENDETEN,
MC34708_ADC0_TSPENDETEN);
else
return mc13xxx_reg_rmw(priv->mc13xxx, MC13XXX_ADC0,
MC34708_ADC0_TSPENDETEN, 0);
}
static struct mc13xxx_driver_data mc13783_driver_data = {
.type = MC13XXX_TYPE_MC13783,
.set_pen_detection = mc13783_set_pen_detection,
};
static struct mc13xxx_driver_data mc34708_driver_data = {
.type = MC13XXX_TYPE_MC34708,
.set_pen_detection = mc34708_set_pen_detection,
};
static irqreturn_t mc13783_ts_handler(int irq, void *data)
......@@ -97,6 +143,10 @@ static void mc13783_ts_report_sample(struct mc13783_ts_priv *priv)
cr0 = (cr0 + cr1) / 2;
if (priv->drvdata->type == MC13XXX_TYPE_MC34708)
if (cr0 > 4080)
cr0 = 0;
if (!cr0 || !sample_tolerance ||
(x2 - x0 < sample_tolerance &&
y2 - y0 < sample_tolerance)) {
......@@ -147,8 +197,7 @@ static int mc13783_ts_open(struct input_dev *dev)
if (ret)
goto out;
ret = mc13xxx_reg_rmw(priv->mc13xxx, MC13XXX_ADC0,
MC13XXX_ADC0_TSMOD_MASK, MC13XXX_ADC0_TSMOD0);
ret = priv->drvdata->set_pen_detection(priv, 1);
if (ret)
mc13xxx_irq_free(priv->mc13xxx, MC13XXX_IRQ_TS, priv);
out:
......@@ -161,8 +210,7 @@ static void mc13783_ts_close(struct input_dev *dev)
struct mc13783_ts_priv *priv = input_get_drvdata(dev);
mc13xxx_lock(priv->mc13xxx);
mc13xxx_reg_rmw(priv->mc13xxx, MC13XXX_ADC0,
MC13XXX_ADC0_TSMOD_MASK, 0);
priv->drvdata->set_pen_detection(priv, 0);
mc13xxx_irq_free(priv->mc13xxx, MC13XXX_IRQ_TS, priv);
mc13xxx_unlock(priv->mc13xxx);
......@@ -174,6 +222,7 @@ static int __init mc13783_ts_probe(struct platform_device *pdev)
struct mc13783_ts_priv *priv;
struct mc13xxx_ts_platform_data *pdata = dev_get_platdata(&pdev->dev);
struct input_dev *idev;
const struct platform_device_id *id = platform_get_device_id(pdev);
int ret = -ENOMEM;
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
......@@ -184,6 +233,7 @@ static int __init mc13783_ts_probe(struct platform_device *pdev)
INIT_DELAYED_WORK(&priv->work, mc13783_ts_work);
priv->mc13xxx = dev_get_drvdata(pdev->dev.parent);
priv->idev = idev;
priv->drvdata = (void *)id->driver_data;
if (pdata) {
priv->atox = pdata->atox;
......@@ -241,7 +291,21 @@ static int mc13783_ts_remove(struct platform_device *pdev)
return 0;
}
static const struct platform_device_id mc13xxx_ts_idtable[] = {
{
.name = "mc13783-ts",
.driver_data = (kernel_ulong_t)&mc13783_driver_data,
}, {
.name = "mc34708-ts",
.driver_data = (kernel_ulong_t)&mc34708_driver_data,
}, {
/* sentinel */
}
};
MODULE_DEVICE_TABLE(platform, mc13xxx_rtc_idtable);
static struct platform_driver mc13783_ts_driver = {
.id_table = mc13xxx_ts_idtable,
.remove = mc13783_ts_remove,
.driver = {
.name = MC13783_TS_NAME,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment