linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Domen Puncer <domen@coderock.org>
To: Sylvain Munaut <tnt@246tNt.com>
Cc: Dragos Carp <dragos.carp@toptica.com>,
	domen.puncer@telargo.com, linuxppc-embedded@ozlabs.org
Subject: [RFC 1/3] Re: [PATCH] mpc52xx_psc_spi: fix it for CONFIG_PPC_MERGE
Date: Fri, 25 May 2007 10:43:04 +0200	[thread overview]
Message-ID: <20070525084304.GA23149@nd47.coderock.org> (raw)
In-Reply-To: <464ABE97.7090603@246tNt.com>

Hi!

I tried to fix these issues, like suggested.

On 16/05/07 10:19 +0200, Sylvain Munaut wrote:
>  - Chaning port_config in the driver is just wrong ... you should _not_
> do that. That should have been setup by the bootloader or at worse in
> the platform setup code.

[ trimming spi-devel and dbrownell from cc: ]

Setup gpio->port_config to match PSC's set in device tree.

Signed-off-by: Domen Puncer <domen.puncer@telargo.com>

---
 arch/powerpc/platforms/52xx/mpc52xx_common.c |   64 +++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)

Index: work-powerpc.git/arch/powerpc/platforms/52xx/mpc52xx_common.c
===================================================================
--- work-powerpc.git.orig/arch/powerpc/platforms/52xx/mpc52xx_common.c
+++ work-powerpc.git/arch/powerpc/platforms/52xx/mpc52xx_common.c
@@ -75,6 +75,68 @@ mpc52xx_find_ipb_freq(struct device_node
 }
 EXPORT_SYMBOL(mpc52xx_find_ipb_freq);
 
+void __init
+mpc52xx_setup_port_config(void)
+{
+	struct mpc52xx_gpio __iomem *gpio;
+	struct device_node *np, *child = NULL;
+	u32 port_config;
+
+	/* Map zones */
+	gpio = mpc52xx_find_and_map("mpc5200-gpio");
+	if (!gpio) {
+		printk(KERN_ERR __FILE__ ": "
+			"Error while mapping GPIO register for port config. "
+			"Expect some abnormal behavior\n");
+		return;
+	}
+
+	/* Set port config */
+	port_config = in_be32(&gpio->port_config);
+
+	np = of_find_node_by_type(NULL, "soc");
+	if (!np) {
+		printk(KERN_ERR "%s: %i can't find node with type 'soc'\n",
+				__func__, __LINE__);
+		iounmap(gpio);
+		return;
+	}
+
+	while ((child = of_get_next_child(np, child))) {
+		if (of_device_is_compatible(child, "mpc5200-psc")) {
+			int ci = -1;
+			const int *pci;
+
+			pci = of_get_property(child, "cell-index", NULL);
+			if (pci)
+				ci = *pci;
+			if (ci < 0 || ci > 5 || ci == 3 || ci == 4) {
+				printk(KERN_ALERT "%s: %i psc node '%s' has invalid "
+						"cell-index: %i\n", __func__, __LINE__,
+						child->name, ci);
+				continue;
+			}
+
+			port_config &= ~(0x7 << ci*4);
+			if (strcmp(child->name, "ac97") == 0)
+				port_config |= 0x2 << ci*4;	/* AC97 functionality */
+			else if (strcmp(child->name, "serial") == 0)
+				port_config |= 0x5 << ci*4;	/* UARTe with CD */
+			else if (strcmp(child->name, "spi") == 0)
+				port_config |= 0x7 << ci*4;	/* CODEC with MCLK */
+			else
+				printk(KERN_ALERT "%s: %i psc node '%s' not handled\n",
+						__func__, __LINE__, child->name);
+		}
+	}
+	of_node_put(np);
+
+	pr_debug("port_config: old:%x new:%x\n",
+	         in_be32(&gpio->port_config), port_config);
+	out_be32(&gpio->port_config, port_config);
+
+	iounmap(gpio);
+}
 
 void __init
 mpc52xx_setup_cpu(void)
@@ -114,6 +176,8 @@ mpc52xx_setup_cpu(void)
 unmap_regs:
 	if (cdm) iounmap(cdm);
 	if (xlb) iounmap(xlb);
+
+	mpc52xx_setup_port_config();
 }
 
 void __init

  parent reply	other threads:[~2007-05-25  8:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-16  7:37 [PATCH] mpc52xx_psc_spi: fix it for CONFIG_PPC_MERGE Domen Puncer
2007-05-16  8:19 ` Sylvain Munaut
2007-05-16 16:11   ` David Brownell
2007-05-16 16:34     ` Sylvain Munaut
2007-05-18  7:44       ` Dragos Carp
2007-05-25  8:43   ` Domen Puncer [this message]
2007-05-25 14:50     ` [RFC 1/3] " Sylvain Munaut
2007-05-25 17:02       ` Grant Likely
2007-05-25  8:45   ` [RFC 2/3] " Domen Puncer
2007-05-25  8:47   ` [RFC 3/3] " Domen Puncer
2007-05-25 16:34     ` David Brownell
2007-05-25 18:00       ` Domen Puncer
2007-05-21  7:31 ` Dragos Carp

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=20070525084304.GA23149@nd47.coderock.org \
    --to=domen@coderock.org \
    --cc=domen.puncer@telargo.com \
    --cc=dragos.carp@toptica.com \
    --cc=linuxppc-embedded@ozlabs.org \
    --cc=tnt@246tNt.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).