diff --git a/arch/powerpc/sysdev/cpm2.c b/arch/powerpc/sysdev/cpm2.c index f4d72b8..087d2fb 100644 --- a/arch/powerpc/sysdev/cpm2.c +++ b/arch/powerpc/sysdev/cpm2.c @@ -319,6 +319,38 @@ cpm_setbrg(uint brg, uint rate) return ret; } +/* Convert a string to a CPM clock source enum + * + * This function takes a string, typically from a property in the device + * tree, and returns the corresponding "enum cpm_clk" value. +*/ +enum cpm_clk cpm2_clock_source(const char *source) +{ + unsigned int i; + + if (strcasecmp(source, "none") == 0) + return CPM_CLK_NONE; + + if (strncasecmp(source, "brg", 3) == 0) { + i = simple_strtoul(source + 3, NULL, 10); + if ((i >= 1) && (i <= 8)) + return (CPM_BRG1 - 1) + i; + else + return CPM_CLK_DUMMY; + } + + if (strncasecmp(source, "clk", 3) == 0) { + i = simple_strtoul(source + 3, NULL, 10); + if ((i >= 1) && (i <= 20)) + return (CPM_CLK1 - 1) + i; + else + return CPM_CLK_DUMMY; + } + + return CPM_CLK_DUMMY; +} +EXPORT_SYMBOL(cpm2_clock_source); + struct cpm2_ioports { u32 dir, par, sor, odr, dat; u32 res[3]; diff --git a/include/asm-powerpc/cpm2.h b/include/asm-powerpc/cpm2.h index b93a53e..d5998a4 100644 --- a/include/asm-powerpc/cpm2.h +++ b/include/asm-powerpc/cpm2.h @@ -42,6 +42,7 @@ #define CPM_CR_FCC1_SBLOCK (0x10) #define CPM_CR_FCC2_SBLOCK (0x11) #define CPM_CR_FCC3_SBLOCK (0x12) +#define CPM_CR_USB_SBLOCK (0x13) #define CPM_CR_IDMA1_SBLOCK (0x14) #define CPM_CR_IDMA2_SBLOCK (0x15) #define CPM_CR_IDMA3_SBLOCK (0x16) @@ -67,6 +68,7 @@ #define CPM_CR_IDMA2_PAGE (0x08) #define CPM_CR_IDMA3_PAGE (0x09) #define CPM_CR_IDMA4_PAGE (0x0a) +#define CPM_CR_USB_PAGE (0x0b) #define CPM_CR_MCC1_PAGE (0x07) #define CPM_CR_MCC2_PAGE (0x08) @@ -75,6 +77,8 @@ /* CPM2-specific opcodes (see cpm.h for common opcodes) */ #define CPM_CR_START_IDMA ((ushort)0x0009) +#define CPM_CR_USB_STOP_TX ((ushort)0x000a) +#define CPM_CR_USB_RESTART_TX ((ushort)0x000b) #define mk_cr_cmd(PG, SBC, MCN, OP) \ ((PG << 26) | (SBC << 21) | (MCN << 6) | OP) @@ -1205,6 +1209,7 @@ enum cpm_clk { CPM_CLK_DUMMY }; +extern enum cpm_clk cpm2_clock_source(const char *source); extern int cpm2_clk_setup(enum cpm_clk_target target, int clock, int mode); extern int cpm2_smc_clk_setup(enum cpm_clk_target target, int clock);