All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pantelis Antoniou <panto@antoniou-consulting.com>
To: Tony Lindgren <tony@atomide.com>
Cc: Pantelis Antoniou <panto@antoniou-consulting.com>,
	linux-kernel@vger.kernel.org,
	Koen Kooi <koen@dominion.thruhere.net>,
	Matt Porter <mporter@ti.com>, Russ Dill <Russ.Dill@ti.com>,
	linux-omap@vger.kernel.org
Subject: [PATCH 2/3] da8xx-dt: Create da8xx DT adapter device
Date: Thu,  1 Nov 2012 17:18:01 +0200	[thread overview]
Message-ID: <1351783082-11411-3-git-send-email-panto@antoniou-consulting.com> (raw)
In-Reply-To: <1351783082-11411-1-git-send-email-panto@antoniou-consulting.com>

omap_device is going private.

Move the da8xx-dt adapter device to arch/arm/mach-omap2.

Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com>
---
 arch/arm/mach-omap2/Makefile   |   3 +
 arch/arm/mach-omap2/da8xx-dt.c | 197 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 200 insertions(+)
 create mode 100644 arch/arm/mach-omap2/da8xx-dt.c

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index fe40d9e..3a9a0ff 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -200,6 +200,9 @@ ifneq ($(CONFIG_DRM_OMAP),)
 obj-y					+= drm.o
 endif
 
+# AM3XX Device Tree adapters for legacy drivers
+obj-$(CONFIG_SOC_AM33XX)		+= da8xx-dt.o
+
 # Specific board support
 obj-$(CONFIG_MACH_OMAP_GENERIC)		+= board-generic.o
 obj-$(CONFIG_MACH_OMAP_H4)		+= board-h4.o
diff --git a/arch/arm/mach-omap2/da8xx-dt.c b/arch/arm/mach-omap2/da8xx-dt.c
new file mode 100644
index 0000000..d3c6f48
--- /dev/null
+++ b/arch/arm/mach-omap2/da8xx-dt.c
@@ -0,0 +1,197 @@
+/*
+ * DA8XX-DT: Device tree adapter using the legacy driver
+ *
+ * Copyright (C) 2012 Pantelis Antoniou <panto@antoniou-consulting.com>
+ * 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 <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/err.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
+#include <video/da8xx-fb.h>
+#include <linux/pinctrl/pinctrl.h>
+#include <linux/pinctrl/pinmux.h>
+#include <linux/pinctrl/consumer.h>
+#include <linux/clk.h>
+#include <plat/clock.h>
+#include <plat/omap_device.h>
+
+struct da8xx_priv {
+	struct da8xx_lcdc_platform_data lcd_pdata;
+	struct lcd_ctrl_config lcd_cfg;
+	struct display_panel lcd_panel;
+	struct platform_device *lcdc_pdev;
+	struct omap_hwmod *lcdc_oh;
+	struct resource lcdc_res[1];
+	int power_dn_gpio;
+};
+
+static const struct of_device_id of_da8xx_dt_match[] = {
+	{ .compatible = "da8xx-dt", },
+	{},
+};
+
+static int __devinit da8xx_dt_probe(struct platform_device *pdev)
+{
+	struct da8xx_priv *priv;
+	struct clk *disp_pll;
+	struct pinctrl *pinctrl;
+	u32 disp_pll_val;
+	const char *panel_type;
+	int ret = -EINVAL;
+
+	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+	if (priv == NULL) {
+		dev_err(&pdev->dev, "Failed to allocate priv\n");
+		return -ENOMEM;
+	}
+	priv->power_dn_gpio = -1;
+
+	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, "disp-pll",
+			&disp_pll_val);
+	if (ret != 0) {
+		dev_err(&pdev->dev, "Failed to read disp-pll property\n");
+		return ret;
+	}
+
+	ret = of_property_read_string(pdev->dev.of_node, "panel-type",
+			&panel_type);
+	if (ret != 0) {
+		dev_err(&pdev->dev, "Failed to read panel-type property\n");
+		return ret;
+	}
+
+	/* conf_disp_pll(disp_pll); */
+	disp_pll = clk_get(NULL, "dpll_disp_ck");
+	if (IS_ERR(disp_pll)) {
+		dev_err(&pdev->dev, "Cannot clk_get disp_pll\n");
+		return PTR_ERR(disp_pll);
+	}
+	ret = clk_set_rate(disp_pll, disp_pll_val);
+	clk_put(disp_pll);
+	if (ret != 0) {
+		dev_err(&pdev->dev, "Failed to set disp_pll\n");
+		return ret;
+	}
+
+	ret = of_get_named_gpio_flags(pdev->dev.of_node, "powerdn-gpio",
+			0, NULL);
+	if (IS_ERR_VALUE(ret)) {
+		dev_info(&pdev->dev, "No power down GPIO\n");
+	} else {
+		priv->power_dn_gpio = ret;
+
+		ret = devm_gpio_request(&pdev->dev, priv->power_dn_gpio,
+				"da8xx-dt:PDN");
+		if (ret != 0) {
+			dev_err(&pdev->dev, "Failed to gpio_request\n");
+			return ret;
+		}
+
+		ret = gpio_direction_output(priv->power_dn_gpio, 1);
+		if (ret != 0) {
+			dev_err(&pdev->dev, "Failed to set powerdn to 1\n");
+			return ret;
+		}
+	}
+
+	/* display_panel */
+	priv->lcd_panel.panel_type	= QVGA;
+	priv->lcd_panel.max_bpp		= 16;
+	priv->lcd_panel.min_bpp		= 16;
+	priv->lcd_panel.panel_shade	= COLOR_ACTIVE;
+
+	/* lcd_ctrl_config */
+	priv->lcd_cfg.p_disp_panel	= &priv->lcd_panel;
+	priv->lcd_cfg.ac_bias		= 255;
+	priv->lcd_cfg.ac_bias_intrpt	= 0;
+	priv->lcd_cfg.dma_burst_sz	= 16;
+	priv->lcd_cfg.bpp		= 16;
+	priv->lcd_cfg.fdd		= 0x80;
+	priv->lcd_cfg.tft_alt_mode	= 0;
+	priv->lcd_cfg.stn_565_mode	= 0;
+	priv->lcd_cfg.mono_8bit_mode	= 0;
+	priv->lcd_cfg.invert_line_clock	= 1;
+	priv->lcd_cfg.invert_frm_clock	= 1;
+	priv->lcd_cfg.sync_edge		= 0;
+	priv->lcd_cfg.sync_ctrl		= 1;
+	priv->lcd_cfg.raster_order	= 0;
+
+	/* da8xx_lcdc_platform_data */
+	strcpy(priv->lcd_pdata.manu_name, "BBToys");
+	priv->lcd_pdata.controller_data = &priv->lcd_cfg;
+	strcpy(priv->lcd_pdata.type, panel_type);
+
+	priv->lcdc_oh = omap_hwmod_lookup("lcdc");
+	if (priv->lcdc_oh == NULL) {
+		dev_err(&pdev->dev, "Failed to lookup omap_hwmod lcdc\n");
+		return -ENODEV;
+	}
+
+	priv->lcdc_pdev = omap_device_build("da8xx_lcdc", 0, priv->lcdc_oh,
+			&priv->lcd_pdata,
+			sizeof(struct da8xx_lcdc_platform_data),
+			NULL, 0, 0);
+	if (priv->lcdc_pdev == NULL) {
+		dev_err(&pdev->dev, "Failed to build LCDC device\n");
+		return -ENODEV;
+	}
+
+	dev_info(&pdev->dev, "Registered bone LCDC OK.\n");
+
+	platform_set_drvdata(pdev, priv);
+
+	return 0;
+}
+
+static int __devexit da8xx_dt_remove(struct platform_device *pdev)
+{
+	return -EINVAL;	/* not supporting removal yet */
+}
+
+static struct platform_driver da8xx_dt_driver = {
+	.probe		= da8xx_dt_probe,
+	.remove		= __devexit_p(da8xx_dt_remove),
+	.driver		= {
+		.name	= "da8xx-dt",
+		.owner	= THIS_MODULE,
+		.of_match_table = of_da8xx_dt_match,
+	},
+};
+
+static __init int da8xx_dt_init(void)
+{
+	return platform_driver_register(&da8xx_dt_driver);
+}
+
+static __exit void da8xx_dt_exit(void)
+{
+	platform_driver_unregister(&da8xx_dt_driver);
+}
+
+postcore_initcall(da8xx_dt_init);
+module_exit(da8xx_dt_exit);
-- 
1.7.12


  parent reply	other threads:[~2012-10-31 17:25 UTC|newest]

Thread overview: 100+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-01 15:17 [PATCH 0/3] capebus moving omap_devices to mach-omap2 Pantelis Antoniou
2012-10-31 17:52 ` Tony Lindgren
2012-10-31 18:04   ` Pantelis Antoniou
2012-10-31 18:09     ` Tony Lindgren
2012-10-31 18:24       ` Pantelis Antoniou
2012-10-31 19:55       ` Benoit Cousson
2012-10-31 19:55         ` Benoit Cousson
2012-10-31 20:12         ` Pantelis Antoniou
2012-10-31 20:12           ` Pantelis Antoniou
2012-10-31 21:26           ` Tony Lindgren
2012-10-31 21:36             ` Pantelis Antoniou
2012-10-31 21:43               ` Tony Lindgren
2012-10-31 22:00                 ` Pantelis Antoniou
2012-10-31 22:16                   ` Tony Lindgren
2012-10-31 22:14               ` Felipe Balbi
2012-10-31 22:14                 ` Felipe Balbi
2012-11-01  7:02                 ` Pantelis Antoniou
2012-11-01  7:02                   ` Pantelis Antoniou
2012-11-01 10:23                   ` Cousson, Benoit
2012-11-01 10:23                     ` Cousson, Benoit
2012-11-01 10:39                     ` Pantelis Antoniou
2012-11-01 10:39                       ` Pantelis Antoniou
2012-11-01 11:04                       ` Felipe Balbi
2012-11-01 11:04                         ` Felipe Balbi
2012-11-01 11:26                         ` Pantelis Antoniou
2012-11-01 11:26                           ` Pantelis Antoniou
2012-11-01 12:40                           ` Felipe Balbi
2012-11-01 12:40                             ` Felipe Balbi
2012-11-01 12:57                             ` Pantelis Antoniou
2012-11-01 12:57                               ` Pantelis Antoniou
2012-11-01 13:16                               ` Felipe Balbi
2012-11-01 13:16                                 ` Felipe Balbi
2012-11-01 13:35                                 ` Pantelis Antoniou
2012-11-01 13:35                                   ` Pantelis Antoniou
2012-11-01 13:51                                   ` Alan Cox
2012-11-01 13:51                                     ` Alan Cox
2012-11-01 13:59                                     ` Pantelis Antoniou
2012-11-01 13:59                                       ` Pantelis Antoniou
2012-11-01 22:05                                       ` Felipe Balbi
2012-11-01 22:05                                         ` Felipe Balbi
2012-11-01 23:49                                         ` Russ Dill
2012-11-02  8:57                                           ` Felipe Balbi
2012-11-02  8:57                                             ` Felipe Balbi
2012-11-02  9:42                                             ` Russ Dill
2012-11-02 10:39                                               ` Koen Kooi
2012-11-02 10:39                                                 ` Koen Kooi
2012-11-02 11:00                                               ` Felipe Balbi
2012-11-02 11:00                                                 ` Felipe Balbi
2012-11-02 16:44                                                 ` Russ Dill
2012-11-02 11:21                                           ` Alan Cox
2012-11-02 12:32                                             ` Pantelis Antoniou
2012-11-05  0:37                                               ` Grant Likely
2012-11-05 15:37                                                 ` Pantelis Antoniou
2012-11-05 15:37                                                   ` Pantelis Antoniou
2012-11-05 19:10                                                   ` Grant Likely
2012-11-05 19:54                                                     ` Pantelis Antoniou
2012-11-05 19:54                                                       ` Pantelis Antoniou
2012-11-05 20:14                                                       ` Grant Likely
2012-11-05 22:59                                                         ` Joel A Fernandes
2012-11-05 23:58                                                           ` Grant Likely
2012-11-05 23:58                                                             ` Grant Likely
2012-11-06  3:06                                                             ` Joel A Fernandes
2012-11-06  8:14                                                               ` Pantelis Antoniou
2012-11-06  8:14                                                                 ` Pantelis Antoniou
2012-11-06 11:16                                                                 ` Grant Likely
2012-11-06 13:54                                                                   ` Pantelis Antoniou
2012-11-06 13:54                                                                     ` Pantelis Antoniou
2012-11-02 16:07                                             ` Jason Kridner
2012-11-02 16:07                                               ` Jason Kridner
2012-11-02 16:28                                               ` Alan Cox
2012-11-05  1:05                                               ` Grant Likely
2012-11-01 11:26                       ` Cousson, Benoit
2012-11-01 11:26                         ` Cousson, Benoit
2012-11-01 11:39                         ` Pantelis Antoniou
2012-11-01 11:39                           ` Pantelis Antoniou
2012-11-01 12:00                         ` Koen Kooi
2012-11-01 12:00                           ` Koen Kooi
2012-11-01 13:06                           ` Felipe Balbi
2012-11-01 13:06                             ` Felipe Balbi
2012-11-01 13:33                             ` Koen Kooi
2012-11-01 13:33                               ` Koen Kooi
2012-11-02  8:15                           ` Cousson, Benoit
2012-11-02  8:15                             ` Cousson, Benoit
2012-11-02  8:43                             ` Pantelis Antoniou
2012-11-03  8:23                               ` Kevin Hilman
2012-11-05  0:22                               ` Grant Likely
2012-11-05  0:22                                 ` Grant Likely
2012-11-05 13:25                                 ` Pantelis Antoniou
2012-11-05 13:25                                   ` Pantelis Antoniou
2012-11-05 14:34                                   ` Grant Likely
2012-11-05 15:34                                     ` Tony Lindgren
2012-11-05 15:34                                       ` Tony Lindgren
2012-11-05 15:56                                     ` Rob Herring
2012-11-05 15:56                                       ` Rob Herring
2012-11-05 19:40                                       ` Grant Likely
2012-11-01 15:18 ` [PATCH 1/3] omap-device: Remove __init from omap_device_build family functions Pantelis Antoniou
2012-11-01 15:18 ` Pantelis Antoniou [this message]
2012-11-01 14:36   ` [PATCH 2/3] da8xx-dt: Create da8xx DT adapter device Tomi Valkeinen
2012-11-01 14:38     ` Pantelis Antoniou
2012-11-01 15:18 ` [PATCH 3/3] ti-tscadc-dt: Create ti-tscadc-dt " Pantelis Antoniou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1351783082-11411-3-git-send-email-panto@antoniou-consulting.com \
    --to=panto@antoniou-consulting.com \
    --cc=Russ.Dill@ti.com \
    --cc=koen@dominion.thruhere.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=mporter@ti.com \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.