All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Yan <andy.yan@rock-chips.com>
To: airlied@linux.ie, heiko@sntech.de, fabio.estevam@freescale.com,
	rmk+kernel@arm.linux.org.uk
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Grant Likely <grant.likely@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Shawn Guo <shawn.guo@linaro.org>,
	Andy yan <andy.yan@rock-chips.com>,
	Josh Boyer <jwboyer@redhat.com>,
	Sean Paul <seanpaul@chromium.org>,
	Inki Dae <inki.dae@samsung.com>, Dave Airlie <airlied@redhat.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Lucas Stach <l.stach@pengutronix.de>,
	Zubair.Kakakhel@imgtec.com, djkurtz@google.com,
	ykk@rock-chips.com, linux-kernel@vger.kernel.org,
	dri-devel@lists.freedesktop.org, devel@driverdev.osuosl.org,
	devicetree@vger.kernel.org, linux-rockchip@lists.infradead.org,
	jay.xu@rock-chips.com
Subject: [PATCH V5 5/7] dw-hdmi: add support for multi byte register width access
Date: Sat,  8 Nov 2014 13:31:06 +0800	[thread overview]
Message-ID: <1415424666-7663-1-git-send-email-andy.yan@rock-chips.com> (raw)
In-Reply-To: <1415424410-7364-1-git-send-email-andy.yan@rock-chips.com>

On rockchip rk3288, only word(32-bit) accesses are
permitted for hdmi registers.  Byte width accesses (writeb,
readb) generate an imprecise external abort.

Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
---
 drivers/gpu/drm/bridge/dw_hdmi.c | 57 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 55 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index e9e73a7..52158ee 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -126,16 +126,39 @@ struct dw_hdmi {
 
 	unsigned int sample_rate;
 	int ratio;
+	void (*write)(u8 val, void __iomem *addr);
+	u8 (*read)(void __iomem *addr);
+	int reg_shift;
 };
 
+static void dw_hdmi_writel(u8 val, void __iomem *addr)
+{
+	writel(val, addr);
+}
+
+static u8 dw_hdmi_readl(void __iomem *addr)
+{
+	return readl(addr);
+}
+
+static void dw_hdmi_writeb(u8 val, void __iomem *addr)
+{
+	writeb(val, addr);
+}
+
+static u8 dw_hdmi_readb(void __iomem *addr)
+{
+	return readb(addr);
+}
+
 static inline void hdmi_writeb(struct dw_hdmi *hdmi, u8 val, int offset)
 {
-	writeb(val, hdmi->regs + offset);
+	hdmi->write(val, hdmi->regs + (offset << hdmi->reg_shift));
 }
 
 static inline u8 hdmi_readb(struct dw_hdmi *hdmi, int offset)
 {
-	return readb(hdmi->regs + offset);
+	return hdmi->read(hdmi->regs + (offset << hdmi->reg_shift));
 }
 
 static void hdmi_modb(struct dw_hdmi *hdmi, u8 data, u8 mask, unsigned reg)
@@ -1499,6 +1522,36 @@ static int dw_hdmi_bind(struct device *dev, struct device *master, void *data)
 	struct device_node *ddc_node;
 	struct resource *iores;
 	int ret, irq;
+	u32 val = 1;
+
+	hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL);
+	if (!hdmi)
+		return -ENOMEM;
+
+	hdmi->plat_data = plat_data;
+	hdmi->dev = &pdev->dev;
+	hdmi->dev_type = plat_data->dev_type;
+	hdmi->sample_rate = 48000;
+	hdmi->ratio = 100;
+	hdmi->encoder = encoder;
+
+	of_property_read_u32(np, "reg-io-width", &val);
+
+	switch (val) {
+	case 4:
+		hdmi->write = dw_hdmi_writel;
+		hdmi->read = dw_hdmi_readl;
+		hdmi->reg_shift = 2;
+		break;
+	case 1:
+		hdmi->write = dw_hdmi_writeb;
+		hdmi->read = dw_hdmi_readb;
+		hdmi->reg_shift = 0;
+		break;
+	default:
+		dev_err(dev, "reg-io-width must be 1 or 4\n");
+		return -EINVAL;
+	}
 
 	ddc_node = of_parse_phandle(np, "ddc-i2c-bus", 0);
 	if (ddc_node) {
-- 
1.9.1


WARNING: multiple messages have this Message-ID (diff)
From: Andy Yan <andy.yan@rock-chips.com>
To: airlied@linux.ie, heiko@sntech.de, fabio.estevam@freescale.com,
	rmk+kernel@arm.linux.org.uk
Cc: devel@driverdev.osuosl.org, devicetree@vger.kernel.org,
	Zubair.Kakakhel@imgtec.com, Arnd Bergmann <arnd@arndb.de>,
	Josh Boyer <jwboyer@redhat.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	ykk@rock-chips.com, linux-kernel@vger.kernel.org,
	dri-devel@lists.freedesktop.org, Inki Dae <inki.dae@samsung.com>,
	linux-rockchip@lists.infradead.org,
	Rob Herring <robh+dt@kernel.org>,
	Sean Paul <seanpaul@chromium.org>,
	djkurtz@google.com, Philipp Zabel <p.zabel@pengutronix.de>,
	Dave Airlie <airlied@redhat.com>,
	Grant Likely <grant.likely@linaro.org>,
	Andy yan <andy.yan@rock-chips.com>,
	Shawn Guo <shawn.guo@linaro.org>,
	jay.xu@rock-chips.com, Lucas Stach <l.stach@pengutronix.de>
Subject: [PATCH V5 5/7] dw-hdmi: add support for multi byte register width access
Date: Sat,  8 Nov 2014 13:31:06 +0800	[thread overview]
Message-ID: <1415424666-7663-1-git-send-email-andy.yan@rock-chips.com> (raw)
In-Reply-To: <1415424410-7364-1-git-send-email-andy.yan@rock-chips.com>

On rockchip rk3288, only word(32-bit) accesses are
permitted for hdmi registers.  Byte width accesses (writeb,
readb) generate an imprecise external abort.

Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
---
 drivers/gpu/drm/bridge/dw_hdmi.c | 57 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 55 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index e9e73a7..52158ee 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -126,16 +126,39 @@ struct dw_hdmi {
 
 	unsigned int sample_rate;
 	int ratio;
+	void (*write)(u8 val, void __iomem *addr);
+	u8 (*read)(void __iomem *addr);
+	int reg_shift;
 };
 
+static void dw_hdmi_writel(u8 val, void __iomem *addr)
+{
+	writel(val, addr);
+}
+
+static u8 dw_hdmi_readl(void __iomem *addr)
+{
+	return readl(addr);
+}
+
+static void dw_hdmi_writeb(u8 val, void __iomem *addr)
+{
+	writeb(val, addr);
+}
+
+static u8 dw_hdmi_readb(void __iomem *addr)
+{
+	return readb(addr);
+}
+
 static inline void hdmi_writeb(struct dw_hdmi *hdmi, u8 val, int offset)
 {
-	writeb(val, hdmi->regs + offset);
+	hdmi->write(val, hdmi->regs + (offset << hdmi->reg_shift));
 }
 
 static inline u8 hdmi_readb(struct dw_hdmi *hdmi, int offset)
 {
-	return readb(hdmi->regs + offset);
+	return hdmi->read(hdmi->regs + (offset << hdmi->reg_shift));
 }
 
 static void hdmi_modb(struct dw_hdmi *hdmi, u8 data, u8 mask, unsigned reg)
@@ -1499,6 +1522,36 @@ static int dw_hdmi_bind(struct device *dev, struct device *master, void *data)
 	struct device_node *ddc_node;
 	struct resource *iores;
 	int ret, irq;
+	u32 val = 1;
+
+	hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL);
+	if (!hdmi)
+		return -ENOMEM;
+
+	hdmi->plat_data = plat_data;
+	hdmi->dev = &pdev->dev;
+	hdmi->dev_type = plat_data->dev_type;
+	hdmi->sample_rate = 48000;
+	hdmi->ratio = 100;
+	hdmi->encoder = encoder;
+
+	of_property_read_u32(np, "reg-io-width", &val);
+
+	switch (val) {
+	case 4:
+		hdmi->write = dw_hdmi_writel;
+		hdmi->read = dw_hdmi_readl;
+		hdmi->reg_shift = 2;
+		break;
+	case 1:
+		hdmi->write = dw_hdmi_writeb;
+		hdmi->read = dw_hdmi_readb;
+		hdmi->reg_shift = 0;
+		break;
+	default:
+		dev_err(dev, "reg-io-width must be 1 or 4\n");
+		return -EINVAL;
+	}
 
 	ddc_node = of_parse_phandle(np, "ddc-i2c-bus", 0);
 	if (ddc_node) {
-- 
1.9.1

  parent reply	other threads:[~2014-11-08  5:31 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-08  5:26 [PATCH V5 0/7]dw-hdmi: convert imx hdmi to bridge/dw-hdmi Andy Yan
2014-11-08  5:26 ` Andy Yan
2014-11-08  5:28 ` [PATCH V5 1/7] imx-drm: imx-hdmi: split imx soc specific code from imx-hdmi Andy Yan
2014-11-08  5:28   ` Andy Yan
2014-11-10 10:51   ` Zubair Lutfullah Kakakhel
2014-11-10 10:51     ` Zubair Lutfullah Kakakhel
2014-11-10 11:28     ` Andy Yan
2014-11-10 11:28       ` Andy Yan
2014-11-08  5:29 ` [PATCH V5 2/7] dw-hdmi: move imx-hdmi to bridge/dw-hdmi Andy Yan
2014-11-08  5:29   ` Andy Yan
2014-11-08  5:29 ` [PATCH V5 3/7] dw-hdmi: make checkpatch happy Andy Yan
2014-11-08  5:29   ` Andy Yan
2014-11-10  9:22   ` Zubair Lutfullah Kakakhel
2014-11-10  9:22     ` Zubair Lutfullah Kakakhel
2014-11-10  9:28     ` Andy Yan
2014-11-10  9:28       ` Andy Yan
2014-11-10  9:31     ` Andy Yan
2014-11-10  9:31       ` Andy Yan
2014-11-08  5:30 ` [PATCH V5 4/7] dw-hdmi: return defer if can't get ddc i2c adapter Andy Yan
2014-11-08  5:30   ` Andy Yan
2014-11-08  5:31 ` Andy Yan [this message]
2014-11-08  5:31   ` [PATCH V5 5/7] dw-hdmi: add support for multi byte register width access Andy Yan
2014-11-08  5:32 ` [PATCH V5 6/7] dw-hdmi: convert dw-hdmi to drm_bridge mode Andy Yan
2014-11-08  5:32   ` Andy Yan
2014-11-08  5:32 ` [PATCH V5 7/7] dt-bindings: add document for dw-hdmi Andy Yan
2014-11-08  5:32   ` Andy Yan
2014-11-10  9:17   ` Zubair Lutfullah Kakakhel
2014-11-10  9:17     ` Zubair Lutfullah Kakakhel
2014-11-10  9:44     ` Andy Yan
2014-11-10  9:53       ` Zubair Lutfullah Kakakhel
2014-11-10  9:53         ` Zubair Lutfullah Kakakhel
2014-11-10  9:59         ` Andy Yan
2014-11-10  9:59           ` Andy Yan

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=1415424666-7663-1-git-send-email-andy.yan@rock-chips.com \
    --to=andy.yan@rock-chips.com \
    --cc=Zubair.Kakakhel@imgtec.com \
    --cc=airlied@linux.ie \
    --cc=airlied@redhat.com \
    --cc=arnd@arndb.de \
    --cc=devel@driverdev.osuosl.org \
    --cc=devicetree@vger.kernel.org \
    --cc=djkurtz@google.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=fabio.estevam@freescale.com \
    --cc=grant.likely@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=heiko@sntech.de \
    --cc=inki.dae@samsung.com \
    --cc=jay.xu@rock-chips.com \
    --cc=jwboyer@redhat.com \
    --cc=l.stach@pengutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=p.zabel@pengutronix.de \
    --cc=rmk+kernel@arm.linux.org.uk \
    --cc=robh+dt@kernel.org \
    --cc=seanpaul@chromium.org \
    --cc=shawn.guo@linaro.org \
    --cc=ykk@rock-chips.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.