McBSP cleanup and generalization
Subsystems (4)
cover McBSP cleanup and generalization
This is just resend of patches 2-14/14 I posted earlier:
http://marc.info/?l=linux-omap&m=131480421332374&w=2
Patch 1/14 is already in linux-omap, Acked-by from Peter added and I took freedom to thank Janusz by adding Tested-by line as he tested the set on OMAP1.
Jarkko Nikula (13):
omap: mcbsp: Remove unused variables from platform data
omap: mcbsp: Move out omap_mcbsp_register_board_cfg from
plat-omap/devices.c
omap: mcbsp: Implement generic register access
omap: mcbsp: Make wakeup control generic
omap: mcbsp: Make tranceiver configuration control register access
generic
omap: mcbsp: Make threshold based transfer code generic
omap: mcbsp: Use per instance register cache size
omap: mcbsp: Move sidetone clock management to mach-omap2/mcbsp.c
omap: mcbsp: Cleanup sidetone control initialization and make it
generic
omap: mcbsp: Update mcbsp.h include dependencies
omap: mcbsp: Move address definitions to arch/arm/mach-omap1/mcbsp.c
omap: mcbsp: Start generalize omap2_mcbsp_set_clks_src
omap: mcbsp: Start generalize signal muxing functions
arch/arm/mach-omap1/mcbsp.c | 45 ++++ arch/arm/mach-omap2/mcbsp.c | 103 ++++++--- arch/arm/plat-omap/devices.c | 46 ---- arch/arm/plat-omap/include/plat/mcbsp.h | 208 ++++++------------ arch/arm/plat-omap/mcbsp.c | 358 ++++++++++++++----------------- 5 files changed, 342 insertions(+), 418 deletions(-)
Signature · 1 line
1.7.6.3
PATCH RESEND 1/13 omap: mcbsp: Remove unused variables from platform data
These variables got unused after McBSP was converted to use resource structures.
--- arch/arm/plat-omap/include/plat/mcbsp.h | 7 ------- 1 files changed, 0 insertions(+), 7 deletions(-)
arch/arm/plat-omap/include/plat/mcbsp.h +0 -7
@@ -348,14 +348,7 @@ struct omap_mcbsp_ops { };struct omap_mcbsp_platform_data { -unsigned long phys_base; -u8 dma_rx_sync, dma_tx_sync; -u16 rx_irq, tx_irq;struct omap_mcbsp_ops *ops; -#ifdef CONFIG_ARCH_OMAP3 -/* Sidetone block for McBSP 2 and 3 */ -unsigned long phys_base_st; -#endif u16 buffer_size;unsigned int mcbsp_config_type; };
Signature · 1 line
1.7.6.3
PATCH RESEND 2/13 omap: mcbsp: Move out omap_mcbsp_register_board_cfg from plat-omap/devices.c
In reply to Jarkko NikulaOnly OMAP1s are using omap_mcbsp_register_board_cfg after OMAP2+ hwmod conversion so it can be moved to mach-omap1/mcbsp.c.
--- arch/arm/mach-omap1/mcbsp.c | 32 +++++++++++++++++++++ arch/arm/plat-omap/devices.c | 46 ------------------------------- arch/arm/plat-omap/include/plat/mcbsp.h | 2 - 3 files changed, 32 insertions(+), 48 deletions(-)
arch/arm/mach-omap1/mcbsp.c +32 -0
@@ -31,6 +31,7 @@static int dsp_use;static struct clk *api_clk;static struct clk *dsp_clk; +static struct platform_device **omap_mcbsp_devices;static void omap1_mcbsp_request (unsigned int id) {
@@ -369,6 +370,37 @@ static struct omap_mcbsp_platform_data omap16xx_mcbsp_pdata[] = {#define OMAP16XX_MCBSP_COUNT 0#endif +static void omap_mcbsp_register_board_cfg (struct resource *res,int res_count, +struct omap_mcbsp_platform_data *config,int size) +{ +int i; + + omap_mcbsp_devices =kzalloc (size *sizeof (struct platform_device *), +GFP_KERNEL ); +if (!omap_mcbsp_devices) { +printk (KERN_ERR "Could not register McBSP devices\n" ); +return ; + } + +for (i =0 ; i < size; i++) { +struct platform_device *new_mcbsp; +int ret; + + new_mcbsp =platform_device_alloc ("omap-mcbsp" , i +1 ); +if (!new_mcbsp) +continue ; +platform_device_add_resources (new_mcbsp, &res[i * res_count], + res_count); + new_mcbsp->dev.platform_data = &config[i]; + ret =platform_device_add (new_mcbsp); +if (ret) { +platform_device_put (new_mcbsp); +continue ; + } + omap_mcbsp_devices[i] = new_mcbsp; + } +} +static int __init omap1_mcbsp_init (void ) {if (!cpu_class_is_omap1 ())
arch/arm/plat-omap/devices.c +0 -46
54 lines not on this page · raw message
arch/arm/plat-omap/include/plat/mcbsp.h +0 -2
@@ -407,8 +407,6 @@ extern int omap_mcbsp_count, omap_mcbsp_cache_size;#define id_to_mcbsp_ptr (id) mcbsp_ptr[id];int omap_mcbsp_init (void ); -void omap_mcbsp_register_board_cfg (struct resource *res,int res_count, -struct omap_mcbsp_platform_data *config,int size);void omap_mcbsp_config (unsigned int id,const struct omap_mcbsp_reg_cfg * config);#ifdef CONFIG_ARCH_OMAP3 void omap_mcbsp_set_tx_threshold (unsigned int id,u16 threshold);
Signature · 1 line
1.7.6.3
PATCH RESEND 3/13 omap: mcbsp: Implement generic register access
In reply to Jarkko NikulaRegister access can be made more generic by calculating register address offsets runtime from common register definitions and by using reg_size and reg_step variables that are passed via platform data. Common register definitions are possible since McBSP registers are ordered similarly between OMAP versions.
Remove also references to OMAP2+ specific config_type variable from generic McBSP code since other variables and feature flags are better to carry needed information from platform code.
--- arch/arm/mach-omap1/mcbsp.c | 2 + arch/arm/mach-omap2/mcbsp.c | 6 +- arch/arm/plat-omap/include/plat/mcbsp.h | 145 ++++++++++++------------------- arch/arm/plat-omap/mcbsp.c | 45 ++++------ 4 files changed, 82 insertions(+), 116 deletions(-)
arch/arm/mach-omap1/mcbsp.c +2 -0
@@ -391,6 +391,8 @@ static void omap_mcbsp_register_board_cfg(struct resource *res, int res_count,continue ;platform_device_add_resources (new_mcbsp, &res[i * res_count], res_count); + config[i].reg_size =2 ; + config[i].reg_step =2 ; new_mcbsp->dev.platform_data = &config[i]; ret =platform_device_add (new_mcbsp);if (ret) {
arch/arm/mach-omap2/mcbsp.c +5 -1
@@ -126,7 +126,11 @@ static int omap_init_mcbsp(struct omap_hwmod *oh, void *unused)return -ENOMEM ; } - pdata->mcbsp_config_type = oh->class->rev; + pdata->reg_step =4 ; +if (oh->class->rev <MCBSP_CONFIG_TYPE2 ) + pdata->reg_size =2 ; +else + pdata->reg_size =4 ;if (oh->class->rev ==MCBSP_CONFIG_TYPE3 ) {if (id ==2 )
arch/arm/plat-omap/include/plat/mcbsp.h +55 -90
170 lines not on this page · raw message
arch/arm/plat-omap/mcbsp.c +20 -25
77 lines not on this page · raw message
Signature · 1 line
1.7.6.3
PATCH RESEND 4/13 omap: mcbsp: Make wakeup control generic
In reply to Jarkko NikulaCurrently wakeup control code is compiled only when CONFIG_ARCH_OMAP3 is set even it should be available for CONFIG_ARCH_OMAP4 only builds also.
Fix this by making wakeup control generic so that it is executed whenever new feature flag has_wakeup in platform data is set. Currently flag is set for McBSP config types 3 and 4.
Remove also old comments about idle mode settings and HW bug workarounds that were not updated during hwmod conversion.
--- arch/arm/mach-omap2/mcbsp.c | 3 ++ arch/arm/plat-omap/include/plat/mcbsp.h | 3 ++ arch/arm/plat-omap/mcbsp.c | 43 ++++++------------------------ 3 files changed, 15 insertions(+), 34 deletions(-)
arch/arm/mach-omap2/mcbsp.c +3 -0
@@ -141,6 +141,9 @@ static int omap_init_mcbsp(struct omap_hwmod *oh, void *unused) pdata->buffer_size =0x80 ; } +if (oh->class->rev >=MCBSP_CONFIG_TYPE3 ) + pdata->has_wakeup = true; + oh_device[0 ] = oh;if (oh->dev_attr) {
arch/arm/plat-omap/include/plat/mcbsp.h +3 -0
@@ -317,6 +317,9 @@ struct omap_mcbsp_platform_data {u16 buffer_size;u8 reg_size;u8 reg_step; + +/* McBSP platform and instance specific features */ +bool has_wakeup;/* Wakeup capability */ };struct omap_mcbsp_st_data {
arch/arm/plat-omap/mcbsp.c +9 -34
68 lines not on this page · raw message
Signature · 1 line
1.7.6.3
PATCH RESEND 5/13 omap: mcbsp: Make tranceiver configuration control register access generic
In reply to Jarkko NikulaMcBSP transmit and receive configuration control registers must be set up for OMAP2430 and later. Replace is_omap tests in generic code with a new feature flag has_ccr in platform data so that there is no need to change code for any upcoming OMAP version.
--- arch/arm/mach-omap2/mcbsp.c | 6 ++++-- arch/arm/plat-omap/include/plat/mcbsp.h | 1 + arch/arm/plat-omap/mcbsp.c | 8 ++++---- 3 files changed, 9 insertions(+), 6 deletions(-)
arch/arm/mach-omap2/mcbsp.c +4 -2
@@ -127,10 +127,12 @@ static int omap_init_mcbsp(struct omap_hwmod *oh, void *unused) } pdata->reg_step =4 ; -if (oh->class->rev <MCBSP_CONFIG_TYPE2 ) +if (oh->class->rev <MCBSP_CONFIG_TYPE2 ) { pdata->reg_size =2 ; -else + }else { pdata->reg_size =4 ; + pdata->has_ccr = true; + }if (oh->class->rev ==MCBSP_CONFIG_TYPE3 ) {if (id ==2 )
arch/arm/plat-omap/include/plat/mcbsp.h +1 -0
@@ -320,6 +320,7 @@ struct omap_mcbsp_platform_data {/* McBSP platform and instance specific features */ bool has_wakeup;/* Wakeup capability */ +bool has_ccr;/* Transceiver has configuration control registers */ };struct omap_mcbsp_st_data {
arch/arm/plat-omap/mcbsp.c +4 -4
@@ -184,7 +184,7 @@ void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg *config)MCBSP_WRITE (mcbsp,MCR2 , config->mcr2);MCBSP_WRITE (mcbsp,MCR1 , config->mcr1);MCBSP_WRITE (mcbsp,PCR0 , config->pcr0); -if (cpu_is_omap2430 () ||cpu_is_omap34xx () ||cpu_is_omap44xx ()) { +if (mcbsp->pdata->has_ccr) {MCBSP_WRITE (mcbsp,XCCR , config->xccr);MCBSP_WRITE (mcbsp,RCCR , config->rccr); }
@@ -848,7 +848,7 @@ void omap_mcbsp_start(unsigned int id, int tx, int rx)MCBSP_WRITE (mcbsp,SPCR2 , w | (1 <<7 )); } -if (cpu_is_omap2430 () ||cpu_is_omap34xx () ||cpu_is_omap44xx ()) { +if (mcbsp->pdata->has_ccr) {/* Release the transmitter and receiver */ w =MCBSP_READ_CACHE (mcbsp,XCCR ); w &= ~(tx ?XDISABLE :0 );
@@ -878,7 +878,7 @@ void omap_mcbsp_stop(unsigned int id, int tx, int rx)/* Reset transmitter */ tx &=1 ; -if (cpu_is_omap2430 () ||cpu_is_omap34xx () ||cpu_is_omap44xx ()) { +if (mcbsp->pdata->has_ccr) { w =MCBSP_READ_CACHE (mcbsp,XCCR ); w |= (tx ?XDISABLE :0 );MCBSP_WRITE (mcbsp,XCCR , w);
@@ -888,7 +888,7 @@ void omap_mcbsp_stop(unsigned int id, int tx, int rx)/* Reset receiver */ rx &=1 ; -if (cpu_is_omap2430 () ||cpu_is_omap34xx () ||cpu_is_omap44xx ()) { +if (mcbsp->pdata->has_ccr) { w =MCBSP_READ_CACHE (mcbsp,RCCR ); w |= (rx ?RDISABLE :0 );MCBSP_WRITE (mcbsp,RCCR , w);
Signature · 1 line
1.7.6.3
PATCH RESEND 6/13 omap: mcbsp: Make threshold based transfer code generic
In reply to Jarkko NikulaRemove CONFIG_ARCH_OMAP3 conditional compilation and cpu_is_omap34xx test around buffer threshold based transfer and DMA operating mode control. Use instead the buffer_size in platform data to determine when these sysfs controls are exposed and when to access related McBSP registers. Rationale for this is to make code generic and to allow to use it on OMAP4 that also supports threshold based transfers.
Currently buffer_size variable is set only for OMAP3 SoCs but it is easy to extend to OMAP4 and any later OMAP version.
--- arch/arm/plat-omap/include/plat/mcbsp.h | 15 +---- arch/arm/plat-omap/mcbsp.c | 120 +++++++++++++++---------------- 2 files changed, 59 insertions(+), 76 deletions(-)
arch/arm/plat-omap/include/plat/mcbsp.h +1 -14
@@ -354,10 +354,10 @@ struct omap_mcbsp {struct clk *fclk;#ifdef CONFIG_ARCH_OMAP3 struct omap_mcbsp_st_data *st_data; +#endif int dma_op_mode;u16 max_tx_thres;u16 max_rx_thres; -#endif void *reg_cache; };
@@ -377,7 +377,6 @@ extern int omap_mcbsp_count, omap_mcbsp_cache_size;int omap_mcbsp_init (void );void omap_mcbsp_config (unsigned int id,const struct omap_mcbsp_reg_cfg * config); -#ifdef CONFIG_ARCH_OMAP3 void omap_mcbsp_set_tx_threshold (unsigned int id,u16 threshold);void omap_mcbsp_set_rx_threshold (unsigned int id,u16 threshold);u16 omap_mcbsp_get_max_tx_threshold (unsigned int id);
@@ -386,18 +385,6 @@ u16 omap_mcbsp_get_fifo_size(unsigned int id);u16 omap_mcbsp_get_tx_delay (unsigned int id);u16 omap_mcbsp_get_rx_delay (unsigned int id);int omap_mcbsp_get_dma_op_mode (unsigned int id); -#else -static inline void omap_mcbsp_set_tx_threshold (unsigned int id,u16 threshold) -{ } -static inline void omap_mcbsp_set_rx_threshold (unsigned int id,u16 threshold) -{ } -static inline u16 omap_mcbsp_get_max_tx_threshold (unsigned int id) {return 0 ; } -static inline u16 omap_mcbsp_get_max_rx_threshold (unsigned int id) {return 0 ; } -static inline u16 omap_mcbsp_get_fifo_size (unsigned int id) {return 0 ; } -static inline u16 omap_mcbsp_get_tx_delay (unsigned int id) {return 0 ; } -static inline u16 omap_mcbsp_get_rx_delay (unsigned int id) {return 0 ; } -static inline int omap_mcbsp_get_dma_op_mode (unsigned int id) {return 0 ; } -#endif int omap_mcbsp_request (unsigned int id);void omap_mcbsp_free (unsigned int id);void omap_mcbsp_start (unsigned int id,int tx,int rx);
arch/arm/plat-omap/mcbsp.c +58 -62
217 lines not on this page · raw message
Signature · 1 line
1.7.6.3
PATCH RESEND 7/13 omap: mcbsp: Use per instance register cache size
In reply to Jarkko NikulaRationale here is to remove one global variable and to make possible to have variable size McBSP register maps inside SoC.
--- arch/arm/plat-omap/include/plat/mcbsp.h | 3 ++- arch/arm/plat-omap/mcbsp.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-)
arch/arm/plat-omap/include/plat/mcbsp.h +2 -1
@@ -359,6 +359,7 @@ struct omap_mcbsp {u16 max_tx_thres;u16 max_rx_thres;void *reg_cache; +int reg_cache_size; };/**
@@ -370,7 +371,7 @@ struct omap_mcbsp_dev_attr { };extern struct omap_mcbsp **mcbsp_ptr; -extern int omap_mcbsp_count, omap_mcbsp_cache_size; +extern int omap_mcbsp_count;#define omap_mcbsp_check_valid_id (id) (id < omap_mcbsp_count)#define id_to_mcbsp_ptr (id) mcbsp_ptr[id];
arch/arm/plat-omap/mcbsp.c +3 -3
@@ -31,7 +31,7 @@#include "../mach-omap2/cm-regbits-34xx.h" struct omap_mcbsp **mcbsp_ptr; -int omap_mcbsp_count, omap_mcbsp_cache_size; +int omap_mcbsp_count;static void omap_mcbsp_write (struct omap_mcbsp *mcbsp,u16 reg,u32 val) {
@@ -678,7 +678,7 @@ int omap_mcbsp_request(unsigned int id) } mcbsp =id_to_mcbsp_ptr (id); - reg_cache =kzalloc (omap_mcbsp_cache_size,GFP_KERNEL ); + reg_cache =kzalloc (mcbsp->reg_cache_size,GFP_KERNEL );if (!reg_cache) {return -ENOMEM ; }
@@ -1225,7 +1225,7 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev) } } mcbsp->phys_base = res->start; - omap_mcbsp_cache_size =resource_size (res); + mcbsp->reg_cache_size =resource_size (res); mcbsp->io_base =ioremap (res->start,resource_size (res));if (!mcbsp->io_base) { ret = -ENOMEM ;
Signature · 1 line
1.7.6.3
PATCH RESEND 8/13 omap: mcbsp: Move sidetone clock management to mach-omap2/mcbsp.c
In reply to Jarkko NikulaFrom: Jarkko Nikula <[email protected]>
Active sidetone requires that McBSP interface clock doesn't idle and there is no mechanism in hwmod to turn autoidling on/off in runtime. McBSP2 and 3 in OMAP34xx share their interface clock with McBSP sidetone module and that interface clock must be active when the sidetone is operating.
Sidetone has its own autoidle bit which should keep the interface clock active but it is broken. Putting the McBSP core to no-idle mode when the sidetone is active is no good either since it results to higher power consumption when using the threshold based DMA transfers.
For making the McBSP code more generic, move this sidetone clock management with fixme comments to mach-omap2/mcbsp.c and pass pointer to it via platform data.
---
Yep, just moving fixme code around but at least it can be fixing now under right architecture. Even if plat/mcbsp.c is moved out.
--- arch/arm/mach-omap2/mcbsp.c | 26 ++++++++++++++++++++++++++ arch/arm/plat-omap/include/plat/mcbsp.h | 1 + arch/arm/plat-omap/mcbsp.c | 18 ++++-------------- 3 files changed, 31 insertions(+), 14 deletions(-)
arch/arm/mach-omap2/mcbsp.c +26 -0
@@ -27,6 +27,13 @@#include "control.h" +/* +* FIXME: Find a mechanism to enable/disable runtime the McBSP ICLK autoidle. +* Sidetone needs non-gated ICLK and sidetone autoidle is broken. +*/ +#include "cm2xxx_3xxx.h" +#include "cm-regbits-34xx.h" +/* McBSP internal signal muxing functions */ void omap2_mcbsp1_mux_clkr_src (u8 mux)
@@ -102,6 +109,24 @@ int omap2_mcbsp_set_clks_src(u8 id, u8 fck_src_id) }EXPORT_SYMBOL (omap2_mcbsp_set_clks_src); +static int omap3_enable_st_clock (unsigned int id,bool enable) +{ +unsigned int w; + +/* +* Sidetone uses McBSP ICLK - which must not idle when sidetones +* are enabled or sidetones start sounding ugly. +*/ + w =omap2_cm_read_mod_reg (OMAP3430_PER_MOD ,CM_AUTOIDLE ); +if (enable) + w &= ~(1 << (id -2 )); +else + w |=1 << (id -2 ); +omap2_cm_write_mod_reg (w,OMAP3430_PER_MOD ,CM_AUTOIDLE ); + +return 0 ; +} +struct omap_device_pm_latency omap2_mcbsp_latency[] = { { .deactivate_func = omap_device_idle_hwmods,
@@ -151,6 +176,7 @@ static int omap_init_mcbsp(struct omap_hwmod *oh, void *unused)if (oh->dev_attr) { oh_device[1 ] =omap_hwmod_lookup (( (struct omap_mcbsp_dev_attr *)(oh->dev_attr))->sidetone); + pdata->enable_st_clock = omap3_enable_st_clock; count++; } pdev = omap_device_build_ss(name, id, oh_device, count, pdata,
arch/arm/plat-omap/include/plat/mcbsp.h +1 -0
@@ -321,6 +321,7 @@ struct omap_mcbsp_platform_data {/* McBSP platform and instance specific features */ bool has_wakeup;/* Wakeup capability */ bool has_ccr;/* Transceiver has configuration control registers */ +int (*enable_st_clock)(unsigned int ,bool ); };struct omap_mcbsp_st_data {
arch/arm/plat-omap/mcbsp.c +4 -14
@@ -26,10 +26,6 @@#include <plat/mcbsp.h> #include <linux/pm_runtime.h> -/* XXX These "sideways" includes are a sign that something is wrong */ -#include "../mach-omap2/cm2xxx_3xxx.h" -#include "../mach-omap2/cm-regbits-34xx.h" -struct omap_mcbsp **mcbsp_ptr;int omap_mcbsp_count;
@@ -257,13 +253,8 @@ static void omap_st_on(struct omap_mcbsp *mcbsp) {unsigned int w; -/* -* Sidetone uses McBSP ICLK - which must not idle when sidetones -* are enabled or sidetones start sounding ugly. -*/ - w =omap2_cm_read_mod_reg (OMAP3430_PER_MOD ,CM_AUTOIDLE ); - w &= ~(1 << (mcbsp->id -2 )); -omap2_cm_write_mod_reg (w,OMAP3430_PER_MOD ,CM_AUTOIDLE ); +if (mcbsp->pdata->enable_st_clock) + mcbsp->pdata->enable_st_clock (mcbsp->id,1 );/* Enable McBSP Sidetone */ w =MCBSP_READ (mcbsp,SSELCR );
@@ -284,9 +275,8 @@ static void omap_st_off(struct omap_mcbsp *mcbsp) w =MCBSP_READ (mcbsp,SSELCR );MCBSP_WRITE (mcbsp,SSELCR , w & ~(SIDETONEEN )); - w =omap2_cm_read_mod_reg (OMAP3430_PER_MOD ,CM_AUTOIDLE ); - w |=1 << (mcbsp->id -2 ); -omap2_cm_write_mod_reg (w,OMAP3430_PER_MOD ,CM_AUTOIDLE ); +if (mcbsp->pdata->enable_st_clock) + mcbsp->pdata->enable_st_clock (mcbsp->id,0 ); }static void omap_st_fir_write (struct omap_mcbsp *mcbsp,s16 *fir)
Signature · 1 line
1.7.6.3
PATCH RESEND 9/13 omap: mcbsp: Cleanup sidetone control initialization and make it generic
In reply to Jarkko NikulaSidetone resource is already registered for a device so there is no need for cpu_is_omap34xx() and McBSP port number tests in the driver. We can cleanup and make the code generic by dropping remaining CONFIG_ARCH_OMAP3 conditional compilations and then using sidetone resource and st_data variable for runtime tests.
--- arch/arm/plat-omap/include/plat/mcbsp.h | 12 ------ arch/arm/plat-omap/mcbsp.c | 67 ++++++++++--------------------- 2 files changed, 22 insertions(+), 57 deletions(-)
arch/arm/plat-omap/include/plat/mcbsp.h +0 -12
@@ -353,9 +353,7 @@ struct omap_mcbsp {spinlock_t lock;struct omap_mcbsp_platform_data *pdata;struct clk *fclk; -#ifdef CONFIG_ARCH_OMAP3 struct omap_mcbsp_st_data *st_data; -#endif int dma_op_mode;u16 max_tx_thres;u16 max_rx_thres;
@@ -402,21 +400,11 @@ void omap2_mcbsp1_mux_fsr_src(u8 mux);int omap_mcbsp_dma_ch_params (unsigned int id,unsigned int stream);int omap_mcbsp_dma_reg_params (unsigned int id,unsigned int stream); -#ifdef CONFIG_ARCH_OMAP3 /* Sidetone specific API */ int omap_st_set_chgain (unsigned int id,int channel,s16 chgain);int omap_st_get_chgain (unsigned int id,int channel,s16 *chgain);int omap_st_enable (unsigned int id);int omap_st_disable (unsigned int id);int omap_st_is_enabled (unsigned int id); -#else -static inline int omap_st_set_chgain (unsigned int id,int channel, -s16 chgain) {return 0 ; } -static inline int omap_st_get_chgain (unsigned int id,int channel, -s16 *chgain) {return 0 ; } -static inline int omap_st_enable (unsigned int id) {return 0 ; } -static inline int omap_st_disable (unsigned int id) {return 0 ; } -static inline int omap_st_is_enabled (unsigned int id) {return 0 ; } -#endif #endif
arch/arm/plat-omap/mcbsp.c +22 -45
144 lines not on this page · raw message
Signature · 1 line
1.7.6.3
PATCH RESEND 10/13 omap: mcbsp: Update mcbsp.h include dependencies
In reply to Jarkko Nikulahardware.h is not needed here and let the definition for struct clk to come via linux/clk.h.
--- arch/arm/plat-omap/include/plat/mcbsp.h | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
arch/arm/plat-omap/include/plat/mcbsp.h +1 -3
@@ -25,9 +25,7 @@#define __ASM_ARCH_OMAP_MCBSP_H#include <linux/spinlock.h> - -#include <mach/hardware.h> -#include <plat/clock.h> +#include <linux/clk.h> /* macro for building platform_device for McBSP ports */ #define OMAP_MCBSP_PLATFORM_DEVICE (port_nr) \
Signature · 1 line
1.7.6.3
PATCH RESEND 11/13 omap: mcbsp: Move address definitions to arch/arm/mach-omap1/mcbsp.c
In reply to Jarkko NikulaThese address definitions are OMAP1 specific can be in single source file.
--- arch/arm/mach-omap1/mcbsp.c | 11 +++++++++++ arch/arm/plat-omap/include/plat/mcbsp.h | 11 ----------- 2 files changed, 11 insertions(+), 11 deletions(-)
arch/arm/mach-omap1/mcbsp.c +11 -0
@@ -79,6 +79,17 @@ static struct omap_mcbsp_ops omap1_mcbsp_ops = { .free = omap1_mcbsp_free, }; +#define OMAP7XX_MCBSP1_BASE 0xfffb1000 +#define OMAP7XX_MCBSP2_BASE 0xfffb1800 + +#define OMAP1510_MCBSP1_BASE 0xe1011800 +#define OMAP1510_MCBSP2_BASE 0xfffb1000 +#define OMAP1510_MCBSP3_BASE 0xe1017000 + +#define OMAP1610_MCBSP1_BASE 0xe1011800 +#define OMAP1610_MCBSP2_BASE 0xfffb1000 +#define OMAP1610_MCBSP3_BASE 0xe1017000 + #if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850) struct resource omap7xx_mcbsp_res[][6] = { {
arch/arm/plat-omap/include/plat/mcbsp.h +0 -11
@@ -38,17 +38,6 @@ static struct platform_device omap_mcbsp##port_nr = { \#define MCBSP_CONFIG_TYPE3 0x3#define MCBSP_CONFIG_TYPE4 0x4 -#define OMAP7XX_MCBSP1_BASE 0xfffb1000 -#define OMAP7XX_MCBSP2_BASE 0xfffb1800 - -#define OMAP1510_MCBSP1_BASE 0xe1011800 -#define OMAP1510_MCBSP2_BASE 0xfffb1000 -#define OMAP1510_MCBSP3_BASE 0xe1017000 - -#define OMAP1610_MCBSP1_BASE 0xe1011800 -#define OMAP1610_MCBSP2_BASE 0xfffb1000 -#define OMAP1610_MCBSP3_BASE 0xe1017000 -/* McBSP register numbers. Register address offset = num * reg_step */ enum {/* Common registers */
Signature · 1 line
1.7.6.3
PATCH RESEND 12/13 omap: mcbsp: Start generalize omap2_mcbsp_set_clks_src
In reply to Jarkko NikulaThis generalizes the omap2_mcbsp_set_clks_src implementation between generic McBSP and OMAP2 specific McBSP code. Currently this function is used to select either internal fclk or clks pin as a McBSP CLKS source on OMAP2+.
Implement generalization by having an optional set_clk_src function pointer in platform data that is used to select parent for a given clock. Idea is to pass higher level source clock name (later coming from client driver) that platform specific code will map to platform specific clock name.
API cleanup between McBSP and client code comes later.
--- arch/arm/mach-omap2/mcbsp.c | 25 ++++++++--------------- arch/arm/plat-omap/include/plat/mcbsp.h | 5 +--- arch/arm/plat-omap/mcbsp.c | 33 +++++++++++++++++++++++------- 3 files changed, 35 insertions(+), 28 deletions(-)
arch/arm/mach-omap2/mcbsp.c +9 -16
@@ -63,37 +63,30 @@ void omap2_mcbsp1_mux_fsr_src(u8 mux)EXPORT_SYMBOL (omap2_mcbsp1_mux_fsr_src);/* McBSP CLKS source switching function */ - -int omap2_mcbsp_set_clks_src (u8 id,u8 fck_src_id) +static int omap2_mcbsp_set_clk_src (struct device *dev,struct clk *clk, +const char *src) { -struct omap_mcbsp *mcbsp;struct clk *fck_src;char *fck_src_name;int r; -if (!omap_mcbsp_check_valid_id (id)) { -pr_err ("%s: Invalid id (%d)\n" , __func__, id +1 ); -return -EINVAL ; - } - mcbsp =id_to_mcbsp_ptr (id); - -if (fck_src_id ==MCBSP_CLKS_PAD_SRC ) +if (!strcmp (src,"clks_ext" )) fck_src_name ="pad_fck" ; -else if (fck_src_id ==MCBSP_CLKS_PRCM_SRC ) +else if (!strcmp (src,"clks_fclk" )) fck_src_name ="prcm_fck" ;else return -EINVAL ; - fck_src =clk_get (mcbsp->dev, fck_src_name); + fck_src =clk_get (dev, fck_src_name);if (IS_ERR_OR_NULL (fck_src)) {pr_err ("omap-mcbsp: %s: could not clk_get() %s\n" ,"clks" , fck_src_name);return -EINVAL ; } -pm_runtime_put_sync (mcbsp->dev); +pm_runtime_put_sync (dev); - r =clk_set_parent (mcbsp->fclk, fck_src); + r =clk_set_parent (clk, fck_src);if (IS_ERR_VALUE (r)) {pr_err ("omap-mcbsp: %s: could not clk_set_parent() to %s\n" ,"clks" , fck_src_name);
@@ -101,13 +94,12 @@ int omap2_mcbsp_set_clks_src(u8 id, u8 fck_src_id)return -EINVAL ; } -pm_runtime_get_sync (mcbsp->dev); +pm_runtime_get_sync (dev);clk_put (fck_src);return 0 ; } -EXPORT_SYMBOL (omap2_mcbsp_set_clks_src);static int omap3_enable_st_clock (unsigned int id,bool enable) {
@@ -188,6 +180,7 @@ static int omap_init_mcbsp(struct omap_hwmod *oh, void *unused) name, oh->name);return PTR_ERR (pdev); } + pdata->set_clk_src = omap2_mcbsp_set_clk_src; omap_mcbsp_count++;return 0 ; }
arch/arm/plat-omap/include/plat/mcbsp.h +1 -4
@@ -296,7 +296,6 @@ typedef enum {struct omap_mcbsp_ops {void (*request)(unsigned int );void (*free)(unsigned int ); -int (*set_clks_src)(u8 ,u8 ); };struct omap_mcbsp_platform_data {
@@ -309,6 +308,7 @@ struct omap_mcbsp_platform_data {bool has_wakeup;/* Wakeup capability */ bool has_ccr;/* Transceiver has configuration control registers */ int (*enable_st_clock)(unsigned int ,bool ); +int (*set_clk_src)(struct device *dev,struct clk *clk,const char *src); };struct omap_mcbsp_st_data {
@@ -359,9 +359,6 @@ struct omap_mcbsp_dev_attr {extern struct omap_mcbsp **mcbsp_ptr;extern int omap_mcbsp_count; -#define omap_mcbsp_check_valid_id (id) (id < omap_mcbsp_count) -#define id_to_mcbsp_ptr (id) mcbsp_ptr[id]; -int omap_mcbsp_init (void );void omap_mcbsp_config (unsigned int id,const struct omap_mcbsp_reg_cfg * config);void omap_mcbsp_set_tx_threshold (unsigned int id,u16 threshold);
arch/arm/plat-omap/mcbsp.c +25 -8
@@ -29,6 +29,9 @@struct omap_mcbsp **mcbsp_ptr;int omap_mcbsp_count; +#define omap_mcbsp_check_valid_id (id) (id < omap_mcbsp_count) +#define id_to_mcbsp_ptr (id) mcbsp_ptr[id]; +static void omap_mcbsp_write (struct omap_mcbsp *mcbsp,u16 reg,u32 val) {void __iomem *addr = mcbsp->io_base + reg * mcbsp->pdata->reg_step;
@@ -894,18 +897,32 @@ void omap_mcbsp_stop(unsigned int id, int tx, int rx) }EXPORT_SYMBOL (omap_mcbsp_stop); -/* -* The following functions are only required on an OMAP1-only build. -* mach-omap2/mcbsp.c contains the real functions -*/ -#ifndef CONFIG_ARCH_OMAP2PLUS int omap2_mcbsp_set_clks_src (u8 id,u8 fck_src_id) { -WARN (1 ,"%s: should never be called on an OMAP1-only kernel\n" , - __func__); -return -EINVAL ; +struct omap_mcbsp *mcbsp; +const char *src; + +if (!omap_mcbsp_check_valid_id (id)) { +pr_err ("%s: Invalid id (%d)\n" , __func__, id +1 ); +return -EINVAL ; + } + mcbsp =id_to_mcbsp_ptr (id); + +if (fck_src_id ==MCBSP_CLKS_PAD_SRC ) + src ="clks_ext" ; +else if (fck_src_id ==MCBSP_CLKS_PRCM_SRC ) + src ="clks_fclk" ; +else +return -EINVAL ; + +if (mcbsp->pdata->set_clk_src) +return mcbsp->pdata->set_clk_src (mcbsp->dev, mcbsp->fclk, src); +else +return -EINVAL ; } +EXPORT_SYMBOL (omap2_mcbsp_set_clks_src); +#ifndef CONFIG_ARCH_OMAP2PLUS void omap2_mcbsp1_mux_clkr_src (u8 mux) { WARN(1, "%s: should never be called on an OMAP1-only kernel\n",
Signature · 1 line
1.7.6.3
PATCH RESEND 13/13 omap: mcbsp: Start generalize signal muxing functions
In reply to Jarkko NikulaThis generalizes the omap2_mcbsp1_mux_clkr_src and omap2_mcbsp1_mux_fsr_src implementation between generic McBSP and OMAP2 specific McBSP code. These functions are used to select source for CLKR and FSR signals on OMAP2+.
Start generalizing the code by implementing an optional mux_signal function pointer in platform data that will implement the actual muxing and which is called now from omap2_mcbsp1_mux_clkr_src and omap2_mcbsp1_mux_fsr_src. These functions are to be removed later and cleanup the API so that mux_signal gets its arguments directly from client code.
--- arch/arm/mach-omap2/mcbsp.c | 43 +++++++++++++++++------------- arch/arm/plat-omap/include/plat/mcbsp.h | 1 + arch/arm/plat-omap/mcbsp.c | 36 ++++++++++++++++++++------ 3 files changed, 53 insertions(+), 27 deletions(-)
arch/arm/mach-omap2/mcbsp.c +24 -19
@@ -34,33 +34,36 @@#include "cm2xxx_3xxx.h" #include "cm-regbits-34xx.h" -/* McBSP internal signal muxing functions */ - -void omap2_mcbsp1_mux_clkr_src (u8 mux) +/* McBSP internal signal muxing function */ +static int omap2_mcbsp1_mux_rx_clk (struct device *dev,const char *signal, +const char *src) {u32 v; v =omap_ctrl_readl (OMAP2_CONTROL_DEVCONF0 ); -if (mux ==CLKR_SRC_CLKR ) - v &= ~OMAP2_MCBSP1_CLKR_MASK ; -else if (mux ==CLKR_SRC_CLKX ) - v |=OMAP2_MCBSP1_CLKR_MASK ; -omap_ctrl_writel (v,OMAP2_CONTROL_DEVCONF0 ); -} -EXPORT_SYMBOL (omap2_mcbsp1_mux_clkr_src); -void omap2_mcbsp1_mux_fsr_src (u8 mux) -{ -u32 v; +if (!strcmp (signal,"clkr" )) { +if (!strcmp (src,"clkr" )) + v &= ~OMAP2_MCBSP1_CLKR_MASK ; +else if (!strcmp (src,"clkx" )) + v |=OMAP2_MCBSP1_CLKR_MASK ; +else +return -EINVAL ; + }else if (!strcmp (signal,"fsr" )) { +if (!strcmp (src,"fsr" )) + v &= ~OMAP2_MCBSP1_FSR_MASK ; +else if (!strcmp (src,"fsx" )) + v |=OMAP2_MCBSP1_FSR_MASK ; +else +return -EINVAL ; + }else { +return -EINVAL ; + } - v =omap_ctrl_readl (OMAP2_CONTROL_DEVCONF0 ); -if (mux ==FSR_SRC_FSR ) - v &= ~OMAP2_MCBSP1_FSR_MASK ; -else if (mux ==FSR_SRC_FSX ) - v |=OMAP2_MCBSP1_FSR_MASK ;omap_ctrl_writel (v,OMAP2_CONTROL_DEVCONF0 ); + +return 0 ; } -EXPORT_SYMBOL (omap2_mcbsp1_mux_fsr_src);/* McBSP CLKS source switching function */ static int omap2_mcbsp_set_clk_src(struct device *dev, struct clk *clk,
@@ -181,6 +184,8 @@ static int omap_init_mcbsp(struct omap_hwmod *oh, void *unused)return PTR_ERR (pdev); } pdata->set_clk_src = omap2_mcbsp_set_clk_src; +if (id ==1 ) + pdata->mux_signal = omap2_mcbsp1_mux_rx_clk; omap_mcbsp_count++;return 0 ; }
arch/arm/plat-omap/include/plat/mcbsp.h +1 -0
@@ -309,6 +309,7 @@ struct omap_mcbsp_platform_data {bool has_ccr;/* Transceiver has configuration control registers */ int (*enable_st_clock)(unsigned int ,bool );int (*set_clk_src)(struct device *dev,struct clk *clk,const char *src); +int (*mux_signal)(struct device *dev,const char *signal,const char *src); };struct omap_mcbsp_st_data {
arch/arm/plat-omap/mcbsp.c +28 -8
@@ -922,21 +922,41 @@ int omap2_mcbsp_set_clks_src(u8 id, u8 fck_src_id) }EXPORT_SYMBOL (omap2_mcbsp_set_clks_src); -#ifndef CONFIG_ARCH_OMAP2PLUS void omap2_mcbsp1_mux_clkr_src (u8 mux) { -WARN (1 ,"%s: should never be called on an OMAP1-only kernel\n" , - __func__); -return ; +struct omap_mcbsp *mcbsp; +const char *src; + +if (mux ==CLKR_SRC_CLKR ) + src ="clkr" ; +else if (mux ==CLKR_SRC_CLKX ) + src ="clkx" ; +else +return ; + + mcbsp =id_to_mcbsp_ptr (0 ); +if (mcbsp->pdata->mux_signal) + mcbsp->pdata->mux_signal (mcbsp->dev,"clkr" , src); } +EXPORT_SYMBOL (omap2_mcbsp1_mux_clkr_src);void omap2_mcbsp1_mux_fsr_src (u8 mux) { -WARN (1 ,"%s: should never be called on an OMAP1-only kernel\n" , - __func__); -return ; +struct omap_mcbsp *mcbsp; +const char *src; + +if (mux ==FSR_SRC_FSR ) + src ="fsr" ; +else if (mux ==FSR_SRC_FSX ) + src ="fsx" ; +else +return ; + + mcbsp =id_to_mcbsp_ptr (0 ); +if (mcbsp->pdata->mux_signal) + mcbsp->pdata->mux_signal (mcbsp->dev,"fsr" , src); } -#endif +EXPORT_SYMBOL (omap2_mcbsp1_mux_fsr_src);#define max_thres (m) (mcbsp->pdata->buffer_size)#define valid_threshold (m, val) ((val) <= max_thres(m))
Signature · 1 line
1.7.6.3
Tony Lindgren
maintainercover McBSP cleanup and generalization
In reply to Jarkko NikulaQuoted 7 lines · Jarkko Nikula
This is just resend of patches 2-14/14 I posted earlier:
http://marc.info/?l=linux-omap&m=131480421332374&w=2
Patch 1/14 is already in linux-omap, Acked-by from Peter added and I took freedom to thank Janusz by adding Tested-by line as he tested the set on OMAP1.
Thanks, I'll apply these into cleanup branch.
Regards,
Tony