18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci *
38c2ecf20Sopenharmony_ci * Utility functions for the Freescale MPC52xx.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2006 Sylvain Munaut <tnt@246tNt.com>
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * This file is licensed under the terms of the GNU General Public License
88c2ecf20Sopenharmony_ci * version 2. This program is licensed "as is" without any warranty of any
98c2ecf20Sopenharmony_ci * kind, whether express or implied.
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci */
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#undef DEBUG
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#include <linux/gpio.h>
168c2ecf20Sopenharmony_ci#include <linux/kernel.h>
178c2ecf20Sopenharmony_ci#include <linux/spinlock.h>
188c2ecf20Sopenharmony_ci#include <linux/of_platform.h>
198c2ecf20Sopenharmony_ci#include <linux/of_gpio.h>
208c2ecf20Sopenharmony_ci#include <linux/export.h>
218c2ecf20Sopenharmony_ci#include <asm/io.h>
228c2ecf20Sopenharmony_ci#include <asm/prom.h>
238c2ecf20Sopenharmony_ci#include <asm/mpc52xx.h>
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci/* MPC5200 device tree match tables */
268c2ecf20Sopenharmony_cistatic const struct of_device_id mpc52xx_xlb_ids[] __initconst = {
278c2ecf20Sopenharmony_ci	{ .compatible = "fsl,mpc5200-xlb", },
288c2ecf20Sopenharmony_ci	{ .compatible = "mpc5200-xlb", },
298c2ecf20Sopenharmony_ci	{}
308c2ecf20Sopenharmony_ci};
318c2ecf20Sopenharmony_cistatic const struct of_device_id mpc52xx_bus_ids[] __initconst = {
328c2ecf20Sopenharmony_ci	{ .compatible = "fsl,mpc5200-immr", },
338c2ecf20Sopenharmony_ci	{ .compatible = "fsl,mpc5200b-immr", },
348c2ecf20Sopenharmony_ci	{ .compatible = "simple-bus", },
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci	/* depreciated matches; shouldn't be used in new device trees */
378c2ecf20Sopenharmony_ci	{ .compatible = "fsl,lpb", },
388c2ecf20Sopenharmony_ci	{ .type = "builtin", .compatible = "mpc5200", }, /* efika */
398c2ecf20Sopenharmony_ci	{ .type = "soc", .compatible = "mpc5200", }, /* lite5200 */
408c2ecf20Sopenharmony_ci	{}
418c2ecf20Sopenharmony_ci};
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci/*
448c2ecf20Sopenharmony_ci * This variable is mapped in mpc52xx_map_wdt() and used in mpc52xx_restart().
458c2ecf20Sopenharmony_ci * Permanent mapping is required because mpc52xx_restart() can be called
468c2ecf20Sopenharmony_ci * from interrupt context while node mapping (which calls ioremap())
478c2ecf20Sopenharmony_ci * cannot be used at such point.
488c2ecf20Sopenharmony_ci */
498c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(mpc52xx_lock);
508c2ecf20Sopenharmony_cistatic struct mpc52xx_gpt __iomem *mpc52xx_wdt;
518c2ecf20Sopenharmony_cistatic struct mpc52xx_cdm __iomem *mpc52xx_cdm;
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci/*
548c2ecf20Sopenharmony_ci * Configure the XLB arbiter settings to match what Linux expects.
558c2ecf20Sopenharmony_ci */
568c2ecf20Sopenharmony_civoid __init
578c2ecf20Sopenharmony_cimpc5200_setup_xlb_arbiter(void)
588c2ecf20Sopenharmony_ci{
598c2ecf20Sopenharmony_ci	struct device_node *np;
608c2ecf20Sopenharmony_ci	struct mpc52xx_xlb  __iomem *xlb;
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci	np = of_find_matching_node(NULL, mpc52xx_xlb_ids);
638c2ecf20Sopenharmony_ci	xlb = of_iomap(np, 0);
648c2ecf20Sopenharmony_ci	of_node_put(np);
658c2ecf20Sopenharmony_ci	if (!xlb) {
668c2ecf20Sopenharmony_ci		printk(KERN_ERR __FILE__ ": "
678c2ecf20Sopenharmony_ci			"Error mapping XLB in mpc52xx_setup_cpu(). "
688c2ecf20Sopenharmony_ci			"Expect some abnormal behavior\n");
698c2ecf20Sopenharmony_ci		return;
708c2ecf20Sopenharmony_ci	}
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci	/* Configure the XLB Arbiter priorities */
738c2ecf20Sopenharmony_ci	out_be32(&xlb->master_pri_enable, 0xff);
748c2ecf20Sopenharmony_ci	out_be32(&xlb->master_priority, 0x11111111);
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci	/*
778c2ecf20Sopenharmony_ci	 * Disable XLB pipelining
788c2ecf20Sopenharmony_ci	 * (cfr errate 292. We could do this only just before ATA PIO
798c2ecf20Sopenharmony_ci	 *  transaction and re-enable it afterwards ...)
808c2ecf20Sopenharmony_ci	 * Not needed on MPC5200B.
818c2ecf20Sopenharmony_ci	 */
828c2ecf20Sopenharmony_ci	if ((mfspr(SPRN_SVR) & MPC5200_SVR_MASK) == MPC5200_SVR)
838c2ecf20Sopenharmony_ci		out_be32(&xlb->config, in_be32(&xlb->config) | MPC52xx_XLB_CFG_PLDIS);
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci	iounmap(xlb);
868c2ecf20Sopenharmony_ci}
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci/*
898c2ecf20Sopenharmony_ci * This variable is mapped in mpc52xx_map_common_devices and
908c2ecf20Sopenharmony_ci * used in mpc5200_psc_ac97_gpio_reset().
918c2ecf20Sopenharmony_ci */
928c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(gpio_lock);
938c2ecf20Sopenharmony_cistruct mpc52xx_gpio __iomem *simple_gpio;
948c2ecf20Sopenharmony_cistruct mpc52xx_gpio_wkup __iomem *wkup_gpio;
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci/**
978c2ecf20Sopenharmony_ci * mpc52xx_declare_of_platform_devices: register internal devices and children
988c2ecf20Sopenharmony_ci *					of the localplus bus to the of_platform
998c2ecf20Sopenharmony_ci *					bus.
1008c2ecf20Sopenharmony_ci */
1018c2ecf20Sopenharmony_civoid __init mpc52xx_declare_of_platform_devices(void)
1028c2ecf20Sopenharmony_ci{
1038c2ecf20Sopenharmony_ci	/* Find all the 'platform' devices and register them. */
1048c2ecf20Sopenharmony_ci	if (of_platform_populate(NULL, mpc52xx_bus_ids, NULL, NULL))
1058c2ecf20Sopenharmony_ci		pr_err(__FILE__ ": Error while populating devices from DT\n");
1068c2ecf20Sopenharmony_ci}
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci/*
1098c2ecf20Sopenharmony_ci * match tables used by mpc52xx_map_common_devices()
1108c2ecf20Sopenharmony_ci */
1118c2ecf20Sopenharmony_cistatic const struct of_device_id mpc52xx_gpt_ids[] __initconst = {
1128c2ecf20Sopenharmony_ci	{ .compatible = "fsl,mpc5200-gpt", },
1138c2ecf20Sopenharmony_ci	{ .compatible = "mpc5200-gpt", }, /* old */
1148c2ecf20Sopenharmony_ci	{}
1158c2ecf20Sopenharmony_ci};
1168c2ecf20Sopenharmony_cistatic const struct of_device_id mpc52xx_cdm_ids[] __initconst = {
1178c2ecf20Sopenharmony_ci	{ .compatible = "fsl,mpc5200-cdm", },
1188c2ecf20Sopenharmony_ci	{ .compatible = "mpc5200-cdm", }, /* old */
1198c2ecf20Sopenharmony_ci	{}
1208c2ecf20Sopenharmony_ci};
1218c2ecf20Sopenharmony_cistatic const struct of_device_id mpc52xx_gpio_simple[] __initconst = {
1228c2ecf20Sopenharmony_ci	{ .compatible = "fsl,mpc5200-gpio", },
1238c2ecf20Sopenharmony_ci	{}
1248c2ecf20Sopenharmony_ci};
1258c2ecf20Sopenharmony_cistatic const struct of_device_id mpc52xx_gpio_wkup[] __initconst = {
1268c2ecf20Sopenharmony_ci	{ .compatible = "fsl,mpc5200-gpio-wkup", },
1278c2ecf20Sopenharmony_ci	{}
1288c2ecf20Sopenharmony_ci};
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci/**
1328c2ecf20Sopenharmony_ci * mpc52xx_map_common_devices: iomap devices required by common code
1338c2ecf20Sopenharmony_ci */
1348c2ecf20Sopenharmony_civoid __init
1358c2ecf20Sopenharmony_cimpc52xx_map_common_devices(void)
1368c2ecf20Sopenharmony_ci{
1378c2ecf20Sopenharmony_ci	struct device_node *np;
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ci	/* mpc52xx_wdt is mapped here and used in mpc52xx_restart,
1408c2ecf20Sopenharmony_ci	 * possibly from a interrupt context. wdt is only implement
1418c2ecf20Sopenharmony_ci	 * on a gpt0, so check has-wdt property before mapping.
1428c2ecf20Sopenharmony_ci	 */
1438c2ecf20Sopenharmony_ci	for_each_matching_node(np, mpc52xx_gpt_ids) {
1448c2ecf20Sopenharmony_ci		if (of_get_property(np, "fsl,has-wdt", NULL) ||
1458c2ecf20Sopenharmony_ci		    of_get_property(np, "has-wdt", NULL)) {
1468c2ecf20Sopenharmony_ci			mpc52xx_wdt = of_iomap(np, 0);
1478c2ecf20Sopenharmony_ci			of_node_put(np);
1488c2ecf20Sopenharmony_ci			break;
1498c2ecf20Sopenharmony_ci		}
1508c2ecf20Sopenharmony_ci	}
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_ci	/* Clock Distribution Module, used by PSC clock setting function */
1538c2ecf20Sopenharmony_ci	np = of_find_matching_node(NULL, mpc52xx_cdm_ids);
1548c2ecf20Sopenharmony_ci	mpc52xx_cdm = of_iomap(np, 0);
1558c2ecf20Sopenharmony_ci	of_node_put(np);
1568c2ecf20Sopenharmony_ci
1578c2ecf20Sopenharmony_ci	/* simple_gpio registers */
1588c2ecf20Sopenharmony_ci	np = of_find_matching_node(NULL, mpc52xx_gpio_simple);
1598c2ecf20Sopenharmony_ci	simple_gpio = of_iomap(np, 0);
1608c2ecf20Sopenharmony_ci	of_node_put(np);
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci	/* wkup_gpio registers */
1638c2ecf20Sopenharmony_ci	np = of_find_matching_node(NULL, mpc52xx_gpio_wkup);
1648c2ecf20Sopenharmony_ci	wkup_gpio = of_iomap(np, 0);
1658c2ecf20Sopenharmony_ci	of_node_put(np);
1668c2ecf20Sopenharmony_ci}
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_ci/**
1698c2ecf20Sopenharmony_ci * mpc52xx_set_psc_clkdiv: Set clock divider in the CDM for PSC ports
1708c2ecf20Sopenharmony_ci *
1718c2ecf20Sopenharmony_ci * @psc_id: id of psc port; must be 1,2,3 or 6
1728c2ecf20Sopenharmony_ci * @clkdiv: clock divider value to put into CDM PSC register.
1738c2ecf20Sopenharmony_ci */
1748c2ecf20Sopenharmony_ciint mpc52xx_set_psc_clkdiv(int psc_id, int clkdiv)
1758c2ecf20Sopenharmony_ci{
1768c2ecf20Sopenharmony_ci	unsigned long flags;
1778c2ecf20Sopenharmony_ci	u16 __iomem *reg;
1788c2ecf20Sopenharmony_ci	u32 val;
1798c2ecf20Sopenharmony_ci	u32 mask;
1808c2ecf20Sopenharmony_ci	u32 mclken_div;
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci	if (!mpc52xx_cdm)
1838c2ecf20Sopenharmony_ci		return -ENODEV;
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci	mclken_div = 0x8000 | (clkdiv & 0x1FF);
1868c2ecf20Sopenharmony_ci	switch (psc_id) {
1878c2ecf20Sopenharmony_ci	case 1: reg = &mpc52xx_cdm->mclken_div_psc1; mask = 0x20; break;
1888c2ecf20Sopenharmony_ci	case 2: reg = &mpc52xx_cdm->mclken_div_psc2; mask = 0x40; break;
1898c2ecf20Sopenharmony_ci	case 3: reg = &mpc52xx_cdm->mclken_div_psc3; mask = 0x80; break;
1908c2ecf20Sopenharmony_ci	case 6: reg = &mpc52xx_cdm->mclken_div_psc6; mask = 0x10; break;
1918c2ecf20Sopenharmony_ci	default:
1928c2ecf20Sopenharmony_ci		return -ENODEV;
1938c2ecf20Sopenharmony_ci	}
1948c2ecf20Sopenharmony_ci
1958c2ecf20Sopenharmony_ci	/* Set the rate and enable the clock */
1968c2ecf20Sopenharmony_ci	spin_lock_irqsave(&mpc52xx_lock, flags);
1978c2ecf20Sopenharmony_ci	out_be16(reg, mclken_div);
1988c2ecf20Sopenharmony_ci	val = in_be32(&mpc52xx_cdm->clk_enables);
1998c2ecf20Sopenharmony_ci	out_be32(&mpc52xx_cdm->clk_enables, val | mask);
2008c2ecf20Sopenharmony_ci	spin_unlock_irqrestore(&mpc52xx_lock, flags);
2018c2ecf20Sopenharmony_ci
2028c2ecf20Sopenharmony_ci	return 0;
2038c2ecf20Sopenharmony_ci}
2048c2ecf20Sopenharmony_ciEXPORT_SYMBOL(mpc52xx_set_psc_clkdiv);
2058c2ecf20Sopenharmony_ci
2068c2ecf20Sopenharmony_ci/**
2078c2ecf20Sopenharmony_ci * mpc52xx_get_xtal_freq - Get SYS_XTAL_IN frequency for a device
2088c2ecf20Sopenharmony_ci *
2098c2ecf20Sopenharmony_ci * @node: device node
2108c2ecf20Sopenharmony_ci *
2118c2ecf20Sopenharmony_ci * Returns the frequency of the external oscillator clock connected
2128c2ecf20Sopenharmony_ci * to the SYS_XTAL_IN pin, or 0 if it cannot be determined.
2138c2ecf20Sopenharmony_ci */
2148c2ecf20Sopenharmony_ciunsigned int mpc52xx_get_xtal_freq(struct device_node *node)
2158c2ecf20Sopenharmony_ci{
2168c2ecf20Sopenharmony_ci	u32 val;
2178c2ecf20Sopenharmony_ci	unsigned int freq;
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_ci	if (!mpc52xx_cdm)
2208c2ecf20Sopenharmony_ci		return 0;
2218c2ecf20Sopenharmony_ci
2228c2ecf20Sopenharmony_ci	freq = mpc5xxx_get_bus_frequency(node);
2238c2ecf20Sopenharmony_ci	if (!freq)
2248c2ecf20Sopenharmony_ci		return 0;
2258c2ecf20Sopenharmony_ci
2268c2ecf20Sopenharmony_ci	if (in_8(&mpc52xx_cdm->ipb_clk_sel) & 0x1)
2278c2ecf20Sopenharmony_ci		freq *= 2;
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_ci	val  = in_be32(&mpc52xx_cdm->rstcfg);
2308c2ecf20Sopenharmony_ci	if (val & (1 << 5))
2318c2ecf20Sopenharmony_ci		freq *= 8;
2328c2ecf20Sopenharmony_ci	else
2338c2ecf20Sopenharmony_ci		freq *= 4;
2348c2ecf20Sopenharmony_ci	if (val & (1 << 6))
2358c2ecf20Sopenharmony_ci		freq /= 12;
2368c2ecf20Sopenharmony_ci	else
2378c2ecf20Sopenharmony_ci		freq /= 16;
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_ci	return freq;
2408c2ecf20Sopenharmony_ci}
2418c2ecf20Sopenharmony_ciEXPORT_SYMBOL(mpc52xx_get_xtal_freq);
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_ci/**
2448c2ecf20Sopenharmony_ci * mpc52xx_restart: ppc_md->restart hook for mpc5200 using the watchdog timer
2458c2ecf20Sopenharmony_ci */
2468c2ecf20Sopenharmony_civoid __noreturn mpc52xx_restart(char *cmd)
2478c2ecf20Sopenharmony_ci{
2488c2ecf20Sopenharmony_ci	local_irq_disable();
2498c2ecf20Sopenharmony_ci
2508c2ecf20Sopenharmony_ci	/* Turn on the watchdog and wait for it to expire.
2518c2ecf20Sopenharmony_ci	 * It effectively does a reset. */
2528c2ecf20Sopenharmony_ci	if (mpc52xx_wdt) {
2538c2ecf20Sopenharmony_ci		out_be32(&mpc52xx_wdt->mode, 0x00000000);
2548c2ecf20Sopenharmony_ci		out_be32(&mpc52xx_wdt->count, 0x000000ff);
2558c2ecf20Sopenharmony_ci		out_be32(&mpc52xx_wdt->mode, 0x00009004);
2568c2ecf20Sopenharmony_ci	} else
2578c2ecf20Sopenharmony_ci		printk(KERN_ERR __FILE__ ": "
2588c2ecf20Sopenharmony_ci			"mpc52xx_restart: Can't access wdt. "
2598c2ecf20Sopenharmony_ci			"Restart impossible, system halted.\n");
2608c2ecf20Sopenharmony_ci
2618c2ecf20Sopenharmony_ci	while (1);
2628c2ecf20Sopenharmony_ci}
2638c2ecf20Sopenharmony_ci
2648c2ecf20Sopenharmony_ci#define PSC1_RESET     0x1
2658c2ecf20Sopenharmony_ci#define PSC1_SYNC      0x4
2668c2ecf20Sopenharmony_ci#define PSC1_SDATA_OUT 0x1
2678c2ecf20Sopenharmony_ci#define PSC2_RESET     0x2
2688c2ecf20Sopenharmony_ci#define PSC2_SYNC      (0x4<<4)
2698c2ecf20Sopenharmony_ci#define PSC2_SDATA_OUT (0x1<<4)
2708c2ecf20Sopenharmony_ci#define MPC52xx_GPIO_PSC1_MASK 0x7
2718c2ecf20Sopenharmony_ci#define MPC52xx_GPIO_PSC2_MASK (0x7<<4)
2728c2ecf20Sopenharmony_ci
2738c2ecf20Sopenharmony_ci/**
2748c2ecf20Sopenharmony_ci * mpc5200_psc_ac97_gpio_reset: Use gpio pins to reset the ac97 bus
2758c2ecf20Sopenharmony_ci *
2768c2ecf20Sopenharmony_ci * @psc: psc number to reset (only psc 1 and 2 support ac97)
2778c2ecf20Sopenharmony_ci */
2788c2ecf20Sopenharmony_ciint mpc5200_psc_ac97_gpio_reset(int psc_number)
2798c2ecf20Sopenharmony_ci{
2808c2ecf20Sopenharmony_ci	unsigned long flags;
2818c2ecf20Sopenharmony_ci	u32 gpio;
2828c2ecf20Sopenharmony_ci	u32 mux;
2838c2ecf20Sopenharmony_ci	int out;
2848c2ecf20Sopenharmony_ci	int reset;
2858c2ecf20Sopenharmony_ci	int sync;
2868c2ecf20Sopenharmony_ci
2878c2ecf20Sopenharmony_ci	if ((!simple_gpio) || (!wkup_gpio))
2888c2ecf20Sopenharmony_ci		return -ENODEV;
2898c2ecf20Sopenharmony_ci
2908c2ecf20Sopenharmony_ci	switch (psc_number) {
2918c2ecf20Sopenharmony_ci	case 0:
2928c2ecf20Sopenharmony_ci		reset   = PSC1_RESET;           /* AC97_1_RES */
2938c2ecf20Sopenharmony_ci		sync    = PSC1_SYNC;            /* AC97_1_SYNC */
2948c2ecf20Sopenharmony_ci		out     = PSC1_SDATA_OUT;       /* AC97_1_SDATA_OUT */
2958c2ecf20Sopenharmony_ci		gpio    = MPC52xx_GPIO_PSC1_MASK;
2968c2ecf20Sopenharmony_ci		break;
2978c2ecf20Sopenharmony_ci	case 1:
2988c2ecf20Sopenharmony_ci		reset   = PSC2_RESET;           /* AC97_2_RES */
2998c2ecf20Sopenharmony_ci		sync    = PSC2_SYNC;            /* AC97_2_SYNC */
3008c2ecf20Sopenharmony_ci		out     = PSC2_SDATA_OUT;       /* AC97_2_SDATA_OUT */
3018c2ecf20Sopenharmony_ci		gpio    = MPC52xx_GPIO_PSC2_MASK;
3028c2ecf20Sopenharmony_ci		break;
3038c2ecf20Sopenharmony_ci	default:
3048c2ecf20Sopenharmony_ci		pr_err(__FILE__ ": Unable to determine PSC, no ac97 "
3058c2ecf20Sopenharmony_ci		       "cold-reset will be performed\n");
3068c2ecf20Sopenharmony_ci		return -ENODEV;
3078c2ecf20Sopenharmony_ci	}
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_ci	spin_lock_irqsave(&gpio_lock, flags);
3108c2ecf20Sopenharmony_ci
3118c2ecf20Sopenharmony_ci	/* Reconfiure pin-muxing to gpio */
3128c2ecf20Sopenharmony_ci	mux = in_be32(&simple_gpio->port_config);
3138c2ecf20Sopenharmony_ci	out_be32(&simple_gpio->port_config, mux & (~gpio));
3148c2ecf20Sopenharmony_ci
3158c2ecf20Sopenharmony_ci	/* enable gpio pins for output */
3168c2ecf20Sopenharmony_ci	setbits8(&wkup_gpio->wkup_gpioe, reset);
3178c2ecf20Sopenharmony_ci	setbits32(&simple_gpio->simple_gpioe, sync | out);
3188c2ecf20Sopenharmony_ci
3198c2ecf20Sopenharmony_ci	setbits8(&wkup_gpio->wkup_ddr, reset);
3208c2ecf20Sopenharmony_ci	setbits32(&simple_gpio->simple_ddr, sync | out);
3218c2ecf20Sopenharmony_ci
3228c2ecf20Sopenharmony_ci	/* Assert cold reset */
3238c2ecf20Sopenharmony_ci	clrbits32(&simple_gpio->simple_dvo, sync | out);
3248c2ecf20Sopenharmony_ci	clrbits8(&wkup_gpio->wkup_dvo, reset);
3258c2ecf20Sopenharmony_ci
3268c2ecf20Sopenharmony_ci	/* wait for 1 us */
3278c2ecf20Sopenharmony_ci	udelay(1);
3288c2ecf20Sopenharmony_ci
3298c2ecf20Sopenharmony_ci	/* Deassert reset */
3308c2ecf20Sopenharmony_ci	setbits8(&wkup_gpio->wkup_dvo, reset);
3318c2ecf20Sopenharmony_ci
3328c2ecf20Sopenharmony_ci	/* wait at least 200ns */
3338c2ecf20Sopenharmony_ci	/* 7 ~= (200ns * timebase) / ns2sec */
3348c2ecf20Sopenharmony_ci	__delay(7);
3358c2ecf20Sopenharmony_ci
3368c2ecf20Sopenharmony_ci	/* Restore pin-muxing */
3378c2ecf20Sopenharmony_ci	out_be32(&simple_gpio->port_config, mux);
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_ci	spin_unlock_irqrestore(&gpio_lock, flags);
3408c2ecf20Sopenharmony_ci
3418c2ecf20Sopenharmony_ci	return 0;
3428c2ecf20Sopenharmony_ci}
3438c2ecf20Sopenharmony_ciEXPORT_SYMBOL(mpc5200_psc_ac97_gpio_reset);
344