Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 362f9b6f authored by Jochen Friedrich's avatar Jochen Friedrich Committed by Kumar Gala
Browse files

[POWERPC] Move CPM command handling into the cpm drivers



This patch moves the CPM command handling into commproc.c
for CPM1 and cpm2_common.c. This is yet another preparation
to get rid of drivers accessing the CPM via the global cpmp.

Signed-off-by: default avatarJochen Friedrich <jochen@scram.de>
Acked-by: default avatarScott Wood <scottwood@freescale.com>
Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarVitaly Bordug <vitb@kernel.crashing.org>
parent 721c0c8a
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -240,6 +240,34 @@ void __init cpm_reset(void)
#endif
}

static DEFINE_SPINLOCK(cmd_lock);

#define MAX_CR_CMD_LOOPS        10000

int cpm_command(u32 command, u8 opcode)
{
	int i, ret;
	unsigned long flags;

	if (command & 0xffffff0f)
		return -EINVAL;

	spin_lock_irqsave(&cmd_lock, flags);

	ret = 0;
	out_be16(&cpmp->cp_cpcr, command | CPM_CR_FLG | (opcode << 8));
	for (i = 0; i < MAX_CR_CMD_LOOPS; i++)
		if ((in_be16(&cpmp->cp_cpcr) & CPM_CR_FLG) == 0)
			goto out;

	printk(KERN_ERR "%s(): Not able to issue CPM command\n", __FUNCTION__);
	ret = -EIO;
out:
	spin_unlock_irqrestore(&cmd_lock, flags);
	return ret;
}
EXPORT_SYMBOL(cpm_command);

/* We used to do this earlier, but have to postpone as long as possible
 * to ensure the kernel VM is now running.
 */
+25 −0
Original line number Diff line number Diff line
@@ -83,6 +83,31 @@ cpm2_reset(void)
	cpmp = &cpm2_immr->im_cpm;
}

static DEFINE_SPINLOCK(cmd_lock);

#define MAX_CR_CMD_LOOPS        10000

int cpm_command(u32 command, u8 opcode)
{
	int i, ret;
	unsigned long flags;

	spin_lock_irqsave(&cmd_lock, flags);

	ret = 0;
	out_be32(&cpmp->cp_cpcr, command | opcode | CPM_CR_FLG);
	for (i = 0; i < MAX_CR_CMD_LOOPS; i++)
		if ((in_be32(&cpmp->cp_cpcr) & CPM_CR_FLG) == 0)
			goto out;

	printk(KERN_ERR "%s(): Not able to issue CPM command\n", __FUNCTION__);
	ret = -EIO;
out:
	spin_unlock_irqrestore(&cmd_lock, flags);
	return ret;
}
EXPORT_SYMBOL(cpm_command);

/* Set a baud rate generator.  This needs lots of work.  There are
 * eight BRGs, which can be connected to the CPM channels or output
 * as clocks.  The BRGs are in two different block of internal
+1 −9
Original line number Diff line number Diff line
@@ -81,16 +81,8 @@
static inline int fcc_cr_cmd(struct fs_enet_private *fep, u32 op)
{
	const struct fs_platform_info *fpi = fep->fpi;
	int i;

	W32(cpmp, cp_cpcr, fpi->cp_command | op | CPM_CR_FLG);
	for (i = 0; i < MAX_CR_CMD_LOOPS; i++)
		if ((R32(cpmp, cp_cpcr) & CPM_CR_FLG) == 0)
			return 0;

	printk(KERN_ERR "%s(): Not able to issue CPM command\n",
	       __FUNCTION__);
	return 1;
	return cpm_command(fpi->cp_command, op);
}

static int do_pd_setup(struct fs_enet_private *fep)
+1 −10
Original line number Diff line number Diff line
@@ -89,21 +89,12 @@
 * Delay to wait for SCC reset command to complete (in us)
 */
#define SCC_RESET_DELAY		50
#define MAX_CR_CMD_LOOPS	10000

static inline int scc_cr_cmd(struct fs_enet_private *fep, u32 op)
{
	const struct fs_platform_info *fpi = fep->fpi;
	int i;

	W16(cpmp, cp_cpcr, fpi->cp_command | CPM_CR_FLG | (op << 8));
	for (i = 0; i < MAX_CR_CMD_LOOPS; i++)
		if ((R16(cpmp, cp_cpcr) & CPM_CR_FLG) == 0)
			return 0;

	printk(KERN_ERR "%s(): Not able to issue CPM command\n",
		__FUNCTION__);
	return 1;
	return cpm_command(fpi->cp_command, op);
}

static int do_pd_setup(struct fs_enet_private *fep)
+1 −5
Original line number Diff line number Diff line
@@ -52,11 +52,7 @@
#ifdef CONFIG_PPC_CPM_NEW_BINDING
void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd)
{
	u16 __iomem *cpcr = &cpmp->cp_cpcr;

	out_be16(cpcr, port->command | (cmd << 8) | CPM_CR_FLG);
	while (in_be16(cpcr) & CPM_CR_FLG)
		;
	cpm_command(port->command, cmd);
}
#else
void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd)
Loading