Commit b820ce4e authored by Russell King's avatar Russell King Committed by Russell King

[ARM] omap: mcbsp: convert to use fck/ick clocks directly

Rather than introducing a special 'mcbsp_clk' with code behind it in
mach-omap*/mcbsp.c to handle the SoC specifics, arrange for the mcbsp
driver to be like any other driver.  mcbsp requests its fck and ick
clocks directly, and the SoC specific code deals with selecting the
correct clock.

There is one oddity to deal with - OMAP1 fiddles with the DSP clocks
and DSP reset, so we move this to the two callback functions.
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent 1b5715ec
...@@ -132,6 +132,15 @@ static struct omap_clk omap_clks[] = { ...@@ -132,6 +132,15 @@ static struct omap_clk omap_clks[] = {
CLK(NULL, "mpu", &virtual_ck_mpu, CK_16XX | CK_1510 | CK_310), CLK(NULL, "mpu", &virtual_ck_mpu, CK_16XX | CK_1510 | CK_310),
CLK("i2c_omap.1", "i2c_fck", &i2c_fck, CK_16XX | CK_1510 | CK_310), CLK("i2c_omap.1", "i2c_fck", &i2c_fck, CK_16XX | CK_1510 | CK_310),
CLK("i2c_omap.1", "i2c_ick", &i2c_ick, CK_16XX), CLK("i2c_omap.1", "i2c_ick", &i2c_ick, CK_16XX),
CLK("omap-mcbsp.1", "ick", &dspper_ck, CK_16XX),
CLK("omap-mcbsp.1", "ick", &dummy_ck, CK_1510 | CK_310),
CLK("omap-mcbsp.2", "ick", &armper_ck.clk, CK_16XX),
CLK("omap-mcbsp.2", "ick", &dummy_ck, CK_1510 | CK_310),
CLK("omap-mcbsp.3", "ick", &dspper_ck, CK_16XX),
CLK("omap-mcbsp.3", "ick", &dummy_ck, CK_1510 | CK_310),
CLK("omap-mcbsp.1", "fck", &dspxor_ck, CK_16XX | CK_1510 | CK_310),
CLK("omap-mcbsp.2", "fck", &armper_ck.clk, CK_16XX | CK_1510 | CK_310),
CLK("omap-mcbsp.3", "fck", &dspxor_ck, CK_16XX | CK_1510 | CK_310),
}; };
static int omap1_clk_enable_generic(struct clk * clk); static int omap1_clk_enable_generic(struct clk * clk);
......
...@@ -28,9 +28,9 @@ ...@@ -28,9 +28,9 @@
#define DPS_RSTCT2_PER_EN (1 << 0) #define DPS_RSTCT2_PER_EN (1 << 0)
#define DSP_RSTCT2_WD_PER_EN (1 << 1) #define DSP_RSTCT2_WD_PER_EN (1 << 1)
#if defined(CONFIG_ARCH_OMAP15XX) || defined(CONFIG_ARCH_OMAP16XX) static int dsp_use;
const char *clk_names[] = { "dsp_ck", "api_ck", "dspxor_ck" }; static struct clk *api_clk;
#endif static struct clk *dsp_clk;
static void omap1_mcbsp_request(unsigned int id) static void omap1_mcbsp_request(unsigned int id)
{ {
...@@ -39,6 +39,13 @@ static void omap1_mcbsp_request(unsigned int id) ...@@ -39,6 +39,13 @@ static void omap1_mcbsp_request(unsigned int id)
* are DSP public peripherals. * are DSP public peripherals.
*/ */
if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3) { if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3) {
if (dsp_use++ == 0) {
api_clk = clk_get(NULL, "api_clk");
dsp_clk = clk_get(NULL, "dsp_clk");
if (!IS_ERR(api_clk) && !IS_ERR(dsp_clk)) {
clk_enable(api_clk);
clk_enable(dsp_clk);
omap_dsp_request_mem(); omap_dsp_request_mem();
/* /*
* DSP external peripheral reset * DSP external peripheral reset
...@@ -47,12 +54,25 @@ static void omap1_mcbsp_request(unsigned int id) ...@@ -47,12 +54,25 @@ static void omap1_mcbsp_request(unsigned int id)
__raw_writew(__raw_readw(DSP_RSTCT2) | DPS_RSTCT2_PER_EN | __raw_writew(__raw_readw(DSP_RSTCT2) | DPS_RSTCT2_PER_EN |
DSP_RSTCT2_WD_PER_EN, DSP_RSTCT2); DSP_RSTCT2_WD_PER_EN, DSP_RSTCT2);
} }
}
}
} }
static void omap1_mcbsp_free(unsigned int id) static void omap1_mcbsp_free(unsigned int id)
{ {
if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3) if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3) {
if (--dsp_use == 0) {
omap_dsp_release_mem(); omap_dsp_release_mem();
if (!IS_ERR(api_clk)) {
clk_disable(api_clk);
clk_put(api_clk);
}
if (!IS_ERR(dsp_clk)) {
clk_disable(dsp_clk);
clk_put(dsp_clk);
}
}
}
} }
static struct omap_mcbsp_ops omap1_mcbsp_ops = { static struct omap_mcbsp_ops omap1_mcbsp_ops = {
...@@ -94,8 +114,6 @@ static struct omap_mcbsp_platform_data omap15xx_mcbsp_pdata[] = { ...@@ -94,8 +114,6 @@ static struct omap_mcbsp_platform_data omap15xx_mcbsp_pdata[] = {
.rx_irq = INT_McBSP1RX, .rx_irq = INT_McBSP1RX,
.tx_irq = INT_McBSP1TX, .tx_irq = INT_McBSP1TX,
.ops = &omap1_mcbsp_ops, .ops = &omap1_mcbsp_ops,
.clk_names = clk_names,
.num_clks = 3,
}, },
{ {
.phys_base = OMAP1510_MCBSP2_BASE, .phys_base = OMAP1510_MCBSP2_BASE,
...@@ -112,8 +130,6 @@ static struct omap_mcbsp_platform_data omap15xx_mcbsp_pdata[] = { ...@@ -112,8 +130,6 @@ static struct omap_mcbsp_platform_data omap15xx_mcbsp_pdata[] = {
.rx_irq = INT_McBSP3RX, .rx_irq = INT_McBSP3RX,
.tx_irq = INT_McBSP3TX, .tx_irq = INT_McBSP3TX,
.ops = &omap1_mcbsp_ops, .ops = &omap1_mcbsp_ops,
.clk_names = clk_names,
.num_clks = 3,
}, },
}; };
#define OMAP15XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap15xx_mcbsp_pdata) #define OMAP15XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap15xx_mcbsp_pdata)
...@@ -131,8 +147,6 @@ static struct omap_mcbsp_platform_data omap16xx_mcbsp_pdata[] = { ...@@ -131,8 +147,6 @@ static struct omap_mcbsp_platform_data omap16xx_mcbsp_pdata[] = {
.rx_irq = INT_McBSP1RX, .rx_irq = INT_McBSP1RX,
.tx_irq = INT_McBSP1TX, .tx_irq = INT_McBSP1TX,
.ops = &omap1_mcbsp_ops, .ops = &omap1_mcbsp_ops,
.clk_names = clk_names,
.num_clks = 3,
}, },
{ {
.phys_base = OMAP1610_MCBSP2_BASE, .phys_base = OMAP1610_MCBSP2_BASE,
...@@ -149,8 +163,6 @@ static struct omap_mcbsp_platform_data omap16xx_mcbsp_pdata[] = { ...@@ -149,8 +163,6 @@ static struct omap_mcbsp_platform_data omap16xx_mcbsp_pdata[] = {
.rx_irq = INT_McBSP3RX, .rx_irq = INT_McBSP3RX,
.tx_irq = INT_McBSP3TX, .tx_irq = INT_McBSP3TX,
.ops = &omap1_mcbsp_ops, .ops = &omap1_mcbsp_ops,
.clk_names = clk_names,
.num_clks = 3,
}, },
}; };
#define OMAP16XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap16xx_mcbsp_pdata) #define OMAP16XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap16xx_mcbsp_pdata)
......
...@@ -139,16 +139,16 @@ static struct omap_clk omap24xx_clks[] = { ...@@ -139,16 +139,16 @@ static struct omap_clk omap24xx_clks[] = {
CLK(NULL, "gpt11_fck", &gpt11_fck, CK_243X | CK_242X), CLK(NULL, "gpt11_fck", &gpt11_fck, CK_243X | CK_242X),
CLK(NULL, "gpt12_ick", &gpt12_ick, CK_243X | CK_242X), CLK(NULL, "gpt12_ick", &gpt12_ick, CK_243X | CK_242X),
CLK(NULL, "gpt12_fck", &gpt12_fck, CK_243X | CK_242X), CLK(NULL, "gpt12_fck", &gpt12_fck, CK_243X | CK_242X),
CLK("omap-mcbsp.1", "mcbsp_ick", &mcbsp1_ick, CK_243X | CK_242X), CLK("omap-mcbsp.1", "ick", &mcbsp1_ick, CK_243X | CK_242X),
CLK("omap-mcbsp.1", "mcbsp_fck", &mcbsp1_fck, CK_243X | CK_242X), CLK("omap-mcbsp.1", "fck", &mcbsp1_fck, CK_243X | CK_242X),
CLK("omap-mcbsp.2", "mcbsp_ick", &mcbsp2_ick, CK_243X | CK_242X), CLK("omap-mcbsp.2", "ick", &mcbsp2_ick, CK_243X | CK_242X),
CLK("omap-mcbsp.2", "mcbsp_fck", &mcbsp2_fck, CK_243X | CK_242X), CLK("omap-mcbsp.2", "fck", &mcbsp2_fck, CK_243X | CK_242X),
CLK("omap-mcbsp.3", "mcbsp_ick", &mcbsp3_ick, CK_243X), CLK("omap-mcbsp.3", "ick", &mcbsp3_ick, CK_243X),
CLK("omap-mcbsp.3", "mcbsp_fck", &mcbsp3_fck, CK_243X), CLK("omap-mcbsp.3", "fck", &mcbsp3_fck, CK_243X),
CLK("omap-mcbsp.4", "mcbsp_ick", &mcbsp4_ick, CK_243X), CLK("omap-mcbsp.4", "ick", &mcbsp4_ick, CK_243X),
CLK("omap-mcbsp.4", "mcbsp_fck", &mcbsp4_fck, CK_243X), CLK("omap-mcbsp.4", "fck", &mcbsp4_fck, CK_243X),
CLK("omap-mcbsp.5", "mcbsp_ick", &mcbsp5_ick, CK_243X), CLK("omap-mcbsp.5", "ick", &mcbsp5_ick, CK_243X),
CLK("omap-mcbsp.5", "mcbsp_fck", &mcbsp5_fck, CK_243X), CLK("omap-mcbsp.5", "fck", &mcbsp5_fck, CK_243X),
CLK("omap2_mcspi.1", "ick", &mcspi1_ick, CK_243X | CK_242X), CLK("omap2_mcspi.1", "ick", &mcspi1_ick, CK_243X | CK_242X),
CLK("omap2_mcspi.1", "fck", &mcspi1_fck, CK_243X | CK_242X), CLK("omap2_mcspi.1", "fck", &mcspi1_fck, CK_243X | CK_242X),
CLK("omap2_mcspi.2", "ick", &mcspi2_ick, CK_243X | CK_242X), CLK("omap2_mcspi.2", "ick", &mcspi2_ick, CK_243X | CK_242X),
......
...@@ -144,8 +144,8 @@ static struct omap_clk omap34xx_clks[] = { ...@@ -144,8 +144,8 @@ static struct omap_clk omap34xx_clks[] = {
CLK("i2c_omap.3", "i2c_fck", &i2c3_fck, CK_343X), CLK("i2c_omap.3", "i2c_fck", &i2c3_fck, CK_343X),
CLK("i2c_omap.2", "i2c_fck", &i2c2_fck, CK_343X), CLK("i2c_omap.2", "i2c_fck", &i2c2_fck, CK_343X),
CLK("i2c_omap.1", "i2c_fck", &i2c1_fck, CK_343X), CLK("i2c_omap.1", "i2c_fck", &i2c1_fck, CK_343X),
CLK("omap-mcbsp.5", "mcbsp_fck", &mcbsp5_fck, CK_343X), CLK("omap-mcbsp.5", "fck", &mcbsp5_fck, CK_343X),
CLK("omap-mcbsp.1", "mcbsp_fck", &mcbsp1_fck, CK_343X), CLK("omap-mcbsp.1", "fck", &mcbsp1_fck, CK_343X),
CLK(NULL, "core_48m_fck", &core_48m_fck, CK_343X), CLK(NULL, "core_48m_fck", &core_48m_fck, CK_343X),
CLK("omap2_mcspi.4", "fck", &mcspi4_fck, CK_343X), CLK("omap2_mcspi.4", "fck", &mcspi4_fck, CK_343X),
CLK("omap2_mcspi.3", "fck", &mcspi3_fck, CK_343X), CLK("omap2_mcspi.3", "fck", &mcspi3_fck, CK_343X),
...@@ -186,8 +186,8 @@ static struct omap_clk omap34xx_clks[] = { ...@@ -186,8 +186,8 @@ static struct omap_clk omap34xx_clks[] = {
CLK(NULL, "uart1_ick", &uart1_ick, CK_343X), CLK(NULL, "uart1_ick", &uart1_ick, CK_343X),
CLK(NULL, "gpt11_ick", &gpt11_ick, CK_343X), CLK(NULL, "gpt11_ick", &gpt11_ick, CK_343X),
CLK(NULL, "gpt10_ick", &gpt10_ick, CK_343X), CLK(NULL, "gpt10_ick", &gpt10_ick, CK_343X),
CLK("omap-mcbsp.5", "mcbsp_ick", &mcbsp5_ick, CK_343X), CLK("omap-mcbsp.5", "ick", &mcbsp5_ick, CK_343X),
CLK("omap-mcbsp.1", "mcbsp_ick", &mcbsp1_ick, CK_343X), CLK("omap-mcbsp.1", "ick", &mcbsp1_ick, CK_343X),
CLK(NULL, "fac_ick", &fac_ick, CK_3430ES1), CLK(NULL, "fac_ick", &fac_ick, CK_3430ES1),
CLK(NULL, "mailboxes_ick", &mailboxes_ick, CK_343X), CLK(NULL, "mailboxes_ick", &mailboxes_ick, CK_343X),
CLK(NULL, "omapctrl_ick", &omapctrl_ick, CK_343X), CLK(NULL, "omapctrl_ick", &omapctrl_ick, CK_343X),
...@@ -257,12 +257,12 @@ static struct omap_clk omap34xx_clks[] = { ...@@ -257,12 +257,12 @@ static struct omap_clk omap34xx_clks[] = {
CLK(NULL, "gpt4_ick", &gpt4_ick, CK_343X), CLK(NULL, "gpt4_ick", &gpt4_ick, CK_343X),
CLK(NULL, "gpt3_ick", &gpt3_ick, CK_343X), CLK(NULL, "gpt3_ick", &gpt3_ick, CK_343X),
CLK(NULL, "gpt2_ick", &gpt2_ick, CK_343X), CLK(NULL, "gpt2_ick", &gpt2_ick, CK_343X),
CLK("omap-mcbsp.2", "mcbsp_ick", &mcbsp2_ick, CK_343X), CLK("omap-mcbsp.2", "ick", &mcbsp2_ick, CK_343X),
CLK("omap-mcbsp.3", "mcbsp_ick", &mcbsp3_ick, CK_343X), CLK("omap-mcbsp.3", "ick", &mcbsp3_ick, CK_343X),
CLK("omap-mcbsp.4", "mcbsp_ick", &mcbsp4_ick, CK_343X), CLK("omap-mcbsp.4", "ick", &mcbsp4_ick, CK_343X),
CLK("omap-mcbsp.2", "mcbsp_fck", &mcbsp2_fck, CK_343X), CLK("omap-mcbsp.2", "fck", &mcbsp2_fck, CK_343X),
CLK("omap-mcbsp.3", "mcbsp_fck", &mcbsp3_fck, CK_343X), CLK("omap-mcbsp.3", "fck", &mcbsp3_fck, CK_343X),
CLK("omap-mcbsp.4", "mcbsp_fck", &mcbsp4_fck, CK_343X), CLK("omap-mcbsp.4", "fck", &mcbsp4_fck, CK_343X),
CLK(NULL, "emu_src_ck", &emu_src_ck, CK_343X), CLK(NULL, "emu_src_ck", &emu_src_ck, CK_343X),
CLK(NULL, "pclk_fck", &pclk_fck, CK_343X), CLK(NULL, "pclk_fck", &pclk_fck, CK_343X),
CLK(NULL, "pclkx2_fck", &pclkx2_fck, CK_343X), CLK(NULL, "pclkx2_fck", &pclkx2_fck, CK_343X),
......
...@@ -24,8 +24,6 @@ ...@@ -24,8 +24,6 @@
#include <mach/cpu.h> #include <mach/cpu.h>
#include <mach/mcbsp.h> #include <mach/mcbsp.h>
const char *clk_names[] = { "mcbsp_ick", "mcbsp_fck" };
static void omap2_mcbsp2_mux_setup(void) static void omap2_mcbsp2_mux_setup(void)
{ {
omap_cfg_reg(Y15_24XX_MCBSP2_CLKX); omap_cfg_reg(Y15_24XX_MCBSP2_CLKX);
...@@ -57,8 +55,6 @@ static struct omap_mcbsp_platform_data omap2420_mcbsp_pdata[] = { ...@@ -57,8 +55,6 @@ static struct omap_mcbsp_platform_data omap2420_mcbsp_pdata[] = {
.rx_irq = INT_24XX_MCBSP1_IRQ_RX, .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
.tx_irq = INT_24XX_MCBSP1_IRQ_TX, .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
.ops = &omap2_mcbsp_ops, .ops = &omap2_mcbsp_ops,
.clk_names = clk_names,
.num_clks = 2,
}, },
{ {
.phys_base = OMAP24XX_MCBSP2_BASE, .phys_base = OMAP24XX_MCBSP2_BASE,
...@@ -67,8 +63,6 @@ static struct omap_mcbsp_platform_data omap2420_mcbsp_pdata[] = { ...@@ -67,8 +63,6 @@ static struct omap_mcbsp_platform_data omap2420_mcbsp_pdata[] = {
.rx_irq = INT_24XX_MCBSP2_IRQ_RX, .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
.tx_irq = INT_24XX_MCBSP2_IRQ_TX, .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
.ops = &omap2_mcbsp_ops, .ops = &omap2_mcbsp_ops,
.clk_names = clk_names,
.num_clks = 2,
}, },
}; };
#define OMAP2420_MCBSP_PDATA_SZ ARRAY_SIZE(omap2420_mcbsp_pdata) #define OMAP2420_MCBSP_PDATA_SZ ARRAY_SIZE(omap2420_mcbsp_pdata)
...@@ -86,8 +80,6 @@ static struct omap_mcbsp_platform_data omap2430_mcbsp_pdata[] = { ...@@ -86,8 +80,6 @@ static struct omap_mcbsp_platform_data omap2430_mcbsp_pdata[] = {
.rx_irq = INT_24XX_MCBSP1_IRQ_RX, .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
.tx_irq = INT_24XX_MCBSP1_IRQ_TX, .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
.ops = &omap2_mcbsp_ops, .ops = &omap2_mcbsp_ops,
.clk_names = clk_names,
.num_clks = 2,
}, },
{ {
.phys_base = OMAP24XX_MCBSP2_BASE, .phys_base = OMAP24XX_MCBSP2_BASE,
...@@ -96,8 +88,6 @@ static struct omap_mcbsp_platform_data omap2430_mcbsp_pdata[] = { ...@@ -96,8 +88,6 @@ static struct omap_mcbsp_platform_data omap2430_mcbsp_pdata[] = {
.rx_irq = INT_24XX_MCBSP2_IRQ_RX, .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
.tx_irq = INT_24XX_MCBSP2_IRQ_TX, .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
.ops = &omap2_mcbsp_ops, .ops = &omap2_mcbsp_ops,
.clk_names = clk_names,
.num_clks = 2,
}, },
{ {
.phys_base = OMAP2430_MCBSP3_BASE, .phys_base = OMAP2430_MCBSP3_BASE,
...@@ -106,8 +96,6 @@ static struct omap_mcbsp_platform_data omap2430_mcbsp_pdata[] = { ...@@ -106,8 +96,6 @@ static struct omap_mcbsp_platform_data omap2430_mcbsp_pdata[] = {
.rx_irq = INT_24XX_MCBSP3_IRQ_RX, .rx_irq = INT_24XX_MCBSP3_IRQ_RX,
.tx_irq = INT_24XX_MCBSP3_IRQ_TX, .tx_irq = INT_24XX_MCBSP3_IRQ_TX,
.ops = &omap2_mcbsp_ops, .ops = &omap2_mcbsp_ops,
.clk_names = clk_names,
.num_clks = 2,
}, },
{ {
.phys_base = OMAP2430_MCBSP4_BASE, .phys_base = OMAP2430_MCBSP4_BASE,
...@@ -116,8 +104,6 @@ static struct omap_mcbsp_platform_data omap2430_mcbsp_pdata[] = { ...@@ -116,8 +104,6 @@ static struct omap_mcbsp_platform_data omap2430_mcbsp_pdata[] = {
.rx_irq = INT_24XX_MCBSP4_IRQ_RX, .rx_irq = INT_24XX_MCBSP4_IRQ_RX,
.tx_irq = INT_24XX_MCBSP4_IRQ_TX, .tx_irq = INT_24XX_MCBSP4_IRQ_TX,
.ops = &omap2_mcbsp_ops, .ops = &omap2_mcbsp_ops,
.clk_names = clk_names,
.num_clks = 2,
}, },
{ {
.phys_base = OMAP2430_MCBSP5_BASE, .phys_base = OMAP2430_MCBSP5_BASE,
...@@ -126,8 +112,6 @@ static struct omap_mcbsp_platform_data omap2430_mcbsp_pdata[] = { ...@@ -126,8 +112,6 @@ static struct omap_mcbsp_platform_data omap2430_mcbsp_pdata[] = {
.rx_irq = INT_24XX_MCBSP5_IRQ_RX, .rx_irq = INT_24XX_MCBSP5_IRQ_RX,
.tx_irq = INT_24XX_MCBSP5_IRQ_TX, .tx_irq = INT_24XX_MCBSP5_IRQ_TX,
.ops = &omap2_mcbsp_ops, .ops = &omap2_mcbsp_ops,
.clk_names = clk_names,
.num_clks = 2,
}, },
}; };
#define OMAP2430_MCBSP_PDATA_SZ ARRAY_SIZE(omap2430_mcbsp_pdata) #define OMAP2430_MCBSP_PDATA_SZ ARRAY_SIZE(omap2430_mcbsp_pdata)
...@@ -145,8 +129,6 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = { ...@@ -145,8 +129,6 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
.rx_irq = INT_24XX_MCBSP1_IRQ_RX, .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
.tx_irq = INT_24XX_MCBSP1_IRQ_TX, .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
.ops = &omap2_mcbsp_ops, .ops = &omap2_mcbsp_ops,
.clk_names = clk_names,
.num_clks = 2,
}, },
{ {
.phys_base = OMAP34XX_MCBSP2_BASE, .phys_base = OMAP34XX_MCBSP2_BASE,
...@@ -155,8 +137,6 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = { ...@@ -155,8 +137,6 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
.rx_irq = INT_24XX_MCBSP2_IRQ_RX, .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
.tx_irq = INT_24XX_MCBSP2_IRQ_TX, .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
.ops = &omap2_mcbsp_ops, .ops = &omap2_mcbsp_ops,
.clk_names = clk_names,
.num_clks = 2,
}, },
{ {
.phys_base = OMAP34XX_MCBSP3_BASE, .phys_base = OMAP34XX_MCBSP3_BASE,
...@@ -165,8 +145,6 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = { ...@@ -165,8 +145,6 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
.rx_irq = INT_24XX_MCBSP3_IRQ_RX, .rx_irq = INT_24XX_MCBSP3_IRQ_RX,
.tx_irq = INT_24XX_MCBSP3_IRQ_TX, .tx_irq = INT_24XX_MCBSP3_IRQ_TX,
.ops = &omap2_mcbsp_ops, .ops = &omap2_mcbsp_ops,
.clk_names = clk_names,
.num_clks = 2,
}, },
{ {
.phys_base = OMAP34XX_MCBSP4_BASE, .phys_base = OMAP34XX_MCBSP4_BASE,
...@@ -175,8 +153,6 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = { ...@@ -175,8 +153,6 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
.rx_irq = INT_24XX_MCBSP4_IRQ_RX, .rx_irq = INT_24XX_MCBSP4_IRQ_RX,
.tx_irq = INT_24XX_MCBSP4_IRQ_TX, .tx_irq = INT_24XX_MCBSP4_IRQ_TX,
.ops = &omap2_mcbsp_ops, .ops = &omap2_mcbsp_ops,
.clk_names = clk_names,
.num_clks = 2,
}, },
{ {
.phys_base = OMAP34XX_MCBSP5_BASE, .phys_base = OMAP34XX_MCBSP5_BASE,
...@@ -185,8 +161,6 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = { ...@@ -185,8 +161,6 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
.rx_irq = INT_24XX_MCBSP5_IRQ_RX, .rx_irq = INT_24XX_MCBSP5_IRQ_RX,
.tx_irq = INT_24XX_MCBSP5_IRQ_TX, .tx_irq = INT_24XX_MCBSP5_IRQ_TX,
.ops = &omap2_mcbsp_ops, .ops = &omap2_mcbsp_ops,
.clk_names = clk_names,
.num_clks = 2,
}, },
}; };
#define OMAP34XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap34xx_mcbsp_pdata) #define OMAP34XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap34xx_mcbsp_pdata)
......
...@@ -344,8 +344,6 @@ struct omap_mcbsp_platform_data { ...@@ -344,8 +344,6 @@ struct omap_mcbsp_platform_data {
u8 dma_rx_sync, dma_tx_sync; u8 dma_rx_sync, dma_tx_sync;
u16 rx_irq, tx_irq; u16 rx_irq, tx_irq;
struct omap_mcbsp_ops *ops; struct omap_mcbsp_ops *ops;
char const **clk_names;
int num_clks;
}; };
struct omap_mcbsp { struct omap_mcbsp {
...@@ -377,8 +375,8 @@ struct omap_mcbsp { ...@@ -377,8 +375,8 @@ struct omap_mcbsp {
/* Protect the field .free, while checking if the mcbsp is in use */ /* Protect the field .free, while checking if the mcbsp is in use */
spinlock_t lock; spinlock_t lock;
struct omap_mcbsp_platform_data *pdata; struct omap_mcbsp_platform_data *pdata;
struct clk **clks; struct clk *iclk;
int num_clks; struct clk *fclk;
}; };
extern struct omap_mcbsp **mcbsp_ptr; extern struct omap_mcbsp **mcbsp_ptr;
extern int omap_mcbsp_count; extern int omap_mcbsp_count;
......
...@@ -214,7 +214,6 @@ EXPORT_SYMBOL(omap_mcbsp_set_io_type); ...@@ -214,7 +214,6 @@ EXPORT_SYMBOL(omap_mcbsp_set_io_type);
int omap_mcbsp_request(unsigned int id) int omap_mcbsp_request(unsigned int id)
{ {
struct omap_mcbsp *mcbsp; struct omap_mcbsp *mcbsp;
int i;
int err; int err;
if (!omap_mcbsp_check_valid_id(id)) { if (!omap_mcbsp_check_valid_id(id)) {
...@@ -223,23 +222,23 @@ int omap_mcbsp_request(unsigned int id) ...@@ -223,23 +222,23 @@ int omap_mcbsp_request(unsigned int id)
} }
mcbsp = id_to_mcbsp_ptr(id); mcbsp = id_to_mcbsp_ptr(id);
if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->request)
mcbsp->pdata->ops->request(id);
for (i = 0; i < mcbsp->num_clks; i++)
clk_enable(mcbsp->clks[i]);
spin_lock(&mcbsp->lock); spin_lock(&mcbsp->lock);
if (!mcbsp->free) { if (!mcbsp->free) {
dev_err(mcbsp->dev, "McBSP%d is currently in use\n", dev_err(mcbsp->dev, "McBSP%d is currently in use\n",
mcbsp->id); mcbsp->id);
spin_unlock(&mcbsp->lock); spin_unlock(&mcbsp->lock);
return -1; return -EBUSY;
} }
mcbsp->free = 0; mcbsp->free = 0;
spin_unlock(&mcbsp->lock); spin_unlock(&mcbsp->lock);
if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->request)
mcbsp->pdata->ops->request(id);
clk_enable(mcbsp->iclk);
clk_enable(mcbsp->fclk);
/* /*
* Make sure that transmitter, receiver and sample-rate generator are * Make sure that transmitter, receiver and sample-rate generator are
* not running before activating IRQs. * not running before activating IRQs.
...@@ -278,7 +277,6 @@ EXPORT_SYMBOL(omap_mcbsp_request); ...@@ -278,7 +277,6 @@ EXPORT_SYMBOL(omap_mcbsp_request);
void omap_mcbsp_free(unsigned int id) void omap_mcbsp_free(unsigned int id)
{ {
struct omap_mcbsp *mcbsp; struct omap_mcbsp *mcbsp;
int i;
if (!omap_mcbsp_check_valid_id(id)) { if (!omap_mcbsp_check_valid_id(id)) {
printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
...@@ -289,8 +287,14 @@ void omap_mcbsp_free(unsigned int id) ...@@ -289,8 +287,14 @@ void omap_mcbsp_free(unsigned int id)
if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->free) if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->free)
mcbsp->pdata->ops->free(id); mcbsp->pdata->ops->free(id);
for (i = mcbsp->num_clks - 1; i >= 0; i--) clk_disable(mcbsp->fclk);
clk_disable(mcbsp->clks[i]); clk_disable(mcbsp->iclk);
if (mcbsp->io_type == OMAP_MCBSP_IRQ_IO) {
/* Free IRQs */
free_irq(mcbsp->rx_irq, (void *)mcbsp);
free_irq(mcbsp->tx_irq, (void *)mcbsp);
}
spin_lock(&mcbsp->lock); spin_lock(&mcbsp->lock);
if (mcbsp->free) { if (mcbsp->free) {
...@@ -302,12 +306,6 @@ void omap_mcbsp_free(unsigned int id) ...@@ -302,12 +306,6 @@ void omap_mcbsp_free(unsigned int id)
mcbsp->free = 1; mcbsp->free = 1;
spin_unlock(&mcbsp->lock); spin_unlock(&mcbsp->lock);
if (mcbsp->io_type == OMAP_MCBSP_IRQ_IO) {
/* Free IRQs */
free_irq(mcbsp->rx_irq, (void *)mcbsp);
free_irq(mcbsp->tx_irq, (void *)mcbsp);
}
} }
EXPORT_SYMBOL(omap_mcbsp_free); EXPORT_SYMBOL(omap_mcbsp_free);
...@@ -876,7 +874,6 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev) ...@@ -876,7 +874,6 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev)
struct omap_mcbsp_platform_data *pdata = pdev->dev.platform_data; struct omap_mcbsp_platform_data *pdata = pdev->dev.platform_data;
struct omap_mcbsp *mcbsp; struct omap_mcbsp *mcbsp;
int id = pdev->id - 1; int id = pdev->id - 1;
int i;
int ret = 0; int ret = 0;
if (!pdata) { if (!pdata) {
...@@ -899,7 +896,6 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev) ...@@ -899,7 +896,6 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev)
ret = -ENOMEM; ret = -ENOMEM;
goto exit; goto exit;
} }
mcbsp_ptr[id] = mcbsp;
spin_lock_init(&mcbsp->lock); spin_lock_init(&mcbsp->lock);
mcbsp->id = id + 1; mcbsp->id = id + 1;
...@@ -921,39 +917,32 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev) ...@@ -921,39 +917,32 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev)
mcbsp->dma_rx_sync = pdata->dma_rx_sync; mcbsp->dma_rx_sync = pdata->dma_rx_sync;
mcbsp->dma_tx_sync = pdata->dma_tx_sync; mcbsp->dma_tx_sync = pdata->dma_tx_sync;
if (pdata->num_clks) { mcbsp->iclk = clk_get(&pdev->dev, "ick");
mcbsp->num_clks = pdata->num_clks; if (IS_ERR(mcbsp->iclk)) {
mcbsp->clks = kzalloc(mcbsp->num_clks * sizeof(struct clk *), ret = PTR_ERR(mcbsp->iclk);
GFP_KERNEL); dev_err(&pdev->dev, "unable to get ick: %d\n", ret);
if (!mcbsp->clks) { goto err_iclk;
ret = -ENOMEM;
goto exit;
}
for (i = 0; i < mcbsp->num_clks; i++) {
mcbsp->clks[i] = clk_get(&pdev->dev, pdata->clk_names[i]);
if (IS_ERR(mcbsp->clks[i])) {
dev_err(&pdev->dev,
"Invalid %s configuration for McBSP%d.\n",
pdata->clk_names[i], mcbsp->id);
ret = PTR_ERR(mcbsp->clks[i]);
goto err_clk;
}
} }
mcbsp->fclk = clk_get(&pdev->dev, "fck");
if (IS_ERR(mcbsp->fclk)) {
ret = PTR_ERR(mcbsp->fclk);
dev_err(&pdev->dev, "unable to get fck: %d\n", ret);
goto err_fclk;
} }
mcbsp->pdata = pdata; mcbsp->pdata = pdata;
mcbsp->dev = &pdev->dev; mcbsp->dev = &pdev->dev;
mcbsp_ptr[id] = mcbsp;
platform_set_drvdata(pdev, mcbsp); platform_set_drvdata(pdev, mcbsp);
return 0; return 0;
err_clk: err_fclk:
while (i--) clk_put(mcbsp->iclk);
clk_put(mcbsp->clks[i]); err_iclk:
kfree(mcbsp->clks);
iounmap(mcbsp->io_base); iounmap(mcbsp->io_base);
err_ioremap: err_ioremap:
mcbsp->free = 0; kfree(mcbsp);
exit: exit:
return ret; return ret;
} }
...@@ -961,7 +950,6 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev) ...@@ -961,7 +950,6 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev)
static int __devexit omap_mcbsp_remove(struct platform_device *pdev) static int __devexit omap_mcbsp_remove(struct platform_device *pdev)
{ {
struct omap_mcbsp *mcbsp = platform_get_drvdata(pdev); struct omap_mcbsp *mcbsp = platform_get_drvdata(pdev);
int i;
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
if (mcbsp) { if (mcbsp) {
...@@ -970,18 +958,15 @@ static int __devexit omap_mcbsp_remove(struct platform_device *pdev) ...@@ -970,18 +958,15 @@ static int __devexit omap_mcbsp_remove(struct platform_device *pdev)
mcbsp->pdata->ops->free) mcbsp->pdata->ops->free)
mcbsp->pdata->ops->free(mcbsp->id); mcbsp->pdata->ops->free(mcbsp->id);
for (i = mcbsp->num_clks - 1; i >= 0; i--) { clk_disable(mcbsp->fclk);
clk_disable(mcbsp->clks[i]); clk_disable(mcbsp->iclk);
clk_put(mcbsp->clks[i]); clk_put(mcbsp->fclk);
} clk_put(mcbsp->iclk);
iounmap(mcbsp->io_base); iounmap(mcbsp->io_base);
if (mcbsp->num_clks) { mcbsp->fclk = NULL;
kfree(mcbsp->clks); mcbsp->iclk = NULL;
mcbsp->clks = NULL;
mcbsp->num_clks = 0;
}
mcbsp->free = 0; mcbsp->free = 0;
mcbsp->dev = NULL; mcbsp->dev = NULL;
} }
...@@ -1002,4 +987,3 @@ int __init omap_mcbsp_init(void) ...@@ -1002,4 +987,3 @@ int __init omap_mcbsp_init(void)
/* Register the McBSP driver */ /* Register the McBSP driver */
return platform_driver_register(&omap_mcbsp_driver); return platform_driver_register(&omap_mcbsp_driver);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment