Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759023Ab2JaRZI (ORCPT ); Wed, 31 Oct 2012 13:25:08 -0400 Received: from li42-95.members.linode.com ([209.123.162.95]:57339 "EHLO li42-95.members.linode.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758943Ab2JaRZF (ORCPT ); Wed, 31 Oct 2012 13:25:05 -0400 From: Pantelis Antoniou To: Tony Lindgren Cc: Pantelis Antoniou , linux-kernel@vger.kernel.org, Koen Kooi , Matt Porter , Russ Dill , linux-omap@vger.kernel.org Subject: [PATCH 3/3] ti-tscadc-dt: Create ti-tscadc-dt DT adapter device Date: Thu, 1 Nov 2012 17:18:02 +0200 Message-Id: <1351783082-11411-4-git-send-email-panto@antoniou-consulting.com> X-Mailer: git-send-email 1.7.12 In-Reply-To: <1351783082-11411-1-git-send-email-panto@antoniou-consulting.com> References: <1351783082-11411-1-git-send-email-panto@antoniou-consulting.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5705 Lines: 192 omap_device is going private. Move the ti-tscadc-dt adapter device to arch/arm/mach-omap2. Signed-off-by: Pantelis Antoniou --- arch/arm/mach-omap2/Makefile | 1 + arch/arm/mach-omap2/ti-tscadc-dt.c | 155 +++++++++++++++++++++++++++++++++++++ 2 files changed, 156 insertions(+) create mode 100644 arch/arm/mach-omap2/ti-tscadc-dt.c diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile index 3a9a0ff..1eab37b 100644 --- a/arch/arm/mach-omap2/Makefile +++ b/arch/arm/mach-omap2/Makefile @@ -202,6 +202,7 @@ endif # AM3XX Device Tree adapters for legacy drivers obj-$(CONFIG_SOC_AM33XX) += da8xx-dt.o +obj-$(CONFIG_SOC_AM33XX) += ti-tscadc-dt.o # Specific board support obj-$(CONFIG_MACH_OMAP_GENERIC) += board-generic.o diff --git a/arch/arm/mach-omap2/ti-tscadc-dt.c b/arch/arm/mach-omap2/ti-tscadc-dt.c new file mode 100644 index 0000000..0a1a17a --- /dev/null +++ b/arch/arm/mach-omap2/ti-tscadc-dt.c @@ -0,0 +1,155 @@ +/* + * TI-TSCADC-DT: Device tree adapter using the legacy driver + * + * Copyright (C) 2012 Pantelis Antoniou + * Copyright (C) 2012 Texas Instruments Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct ti_tscadc_priv { + struct omap_hwmod *tsc_oh; + struct tsc_data tsc_data; + struct adc_data adc_data; + struct mfd_tscadc_board tscadc_data; + struct platform_device *tscadc_pdev; +}; + +static const struct of_device_id of_ti_tscadc_dt_match[] = { + { .compatible = "ti-tscadc-dt", }, + {}, +}; + +static int __devinit ti_tscadc_dt_probe(struct platform_device *pdev) +{ + struct ti_tscadc_priv *priv; + struct pinctrl *pinctrl; + u32 val; + int ret; + + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); + if (priv == NULL) { + dev_err(&pdev->dev, "Failed to allocate priv\n"); + return -ENOMEM; + } + + pinctrl = devm_pinctrl_get_select_default(&pdev->dev); + if (IS_ERR(pinctrl)) + dev_warn(&pdev->dev, + "pins are not configured from the driver\n"); + + ret = of_property_read_u32(pdev->dev.of_node, "tsc-wires", &val); + if (ret != 0) { + dev_info(&pdev->dev, "no tsc-wires property; disabling TSC\n"); + val = 0; + } + priv->tsc_data.wires = val; + + if (priv->tsc_data.wires > 0) { + ret = of_property_read_u32(pdev->dev.of_node, + "tsc-x-plate-resistance", &val); + if (ret != 0) { + dev_err(&pdev->dev, "Failed to read " + "tsc-x-plate-resistance property\n"); + return ret; + } + priv->tsc_data.x_plate_resistance = val; + + ret = of_property_read_u32(pdev->dev.of_node, + "tsc-steps", &val); + if (ret != 0) { + dev_err(&pdev->dev, "Failed to read " + "tsc-steps property\n"); + return ret; + } + priv->tsc_data.steps_to_configure = val; + } + + ret = of_property_read_u32(pdev->dev.of_node, "adc-channels", &val); + if (ret != 0) { + dev_info(&pdev->dev, "No adc-channels property; " + "disabling adc\n"); + val = 0; + } + priv->adc_data.adc_channels = val; + + priv->tscadc_data.tsc_init = &priv->tsc_data; + priv->tscadc_data.adc_init = &priv->adc_data; + + priv->tsc_oh = omap_hwmod_lookup("adc_tsc"); + if (priv->tsc_oh == NULL) { + dev_err(&pdev->dev, "Could not lookup HWMOD %s\n", "adc_tsc"); + return -ENODEV; + } + + priv->tscadc_pdev = omap_device_build("ti_tscadc", -1, priv->tsc_oh, + &priv->tscadc_data, sizeof(priv->tscadc_data), + NULL, 0, 0); + if (priv->tscadc_pdev == NULL) { + dev_err(&pdev->dev, "Could not create tsc_adc device\n"); + return -ENODEV; + } + + dev_info(&pdev->dev, "TI tscadc pdev created OK\n"); + + platform_set_drvdata(pdev, priv); + + return 0; +} + +static int __devexit ti_tscadc_dt_remove(struct platform_device *pdev) +{ + return -EINVAL; /* not supporting removal yet */ +} + +static struct platform_driver ti_tscadc_dt_driver = { + .probe = ti_tscadc_dt_probe, + .remove = __devexit_p(ti_tscadc_dt_remove), + .driver = { + .name = "ti_tscadc-dt", + .owner = THIS_MODULE, + .of_match_table = of_ti_tscadc_dt_match, + }, +}; + +static __init int ti_tscadc_dt_init(void) +{ + return platform_driver_register(&ti_tscadc_dt_driver); +} + +static __exit void ti_tscadc_dt_exit(void) +{ + platform_driver_unregister(&ti_tscadc_dt_driver); +} + +postcore_initcall(ti_tscadc_dt_init); +module_exit(ti_tscadc_dt_exit); -- 1.7.12 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/