aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJarkko Nikula <jarkko.nikula@bitmer.com>2011-09-26 03:45:45 -0400
committerTony Lindgren <tony@atomide.com>2011-09-26 20:48:34 -0400
commitf821eece8b1bb10ad2d76c026e02257ce5c3c439 (patch)
treecee396aa2f83f7d7290087d400a768c11a4d2922
parent1743d14fb6b428e52a9a0917d11d6eba9a110002 (diff)
ARM: OMAP: mcbsp: Cleanup sidetone control initialization and make it generic
Sidetone 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. Signed-off-by: Jarkko Nikula <jarkko.nikula@bitmer.com> Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Tested-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> Signed-off-by: Tony Lindgren <tony@atomide.com>
-rw-r--r--arch/arm/plat-omap/include/plat/mcbsp.h12
-rw-r--r--arch/arm/plat-omap/mcbsp.c67
2 files changed, 22 insertions, 57 deletions
diff --git a/arch/arm/plat-omap/include/plat/mcbsp.h b/arch/arm/plat-omap/include/plat/mcbsp.h
index e451a6e8b065..9802055b0a80 100644
--- a/arch/arm/plat-omap/include/plat/mcbsp.h
+++ b/arch/arm/plat-omap/include/plat/mcbsp.h
@@ -353,9 +353,7 @@ struct omap_mcbsp {
353 spinlock_t lock; 353 spinlock_t lock;
354 struct omap_mcbsp_platform_data *pdata; 354 struct omap_mcbsp_platform_data *pdata;
355 struct clk *fclk; 355 struct clk *fclk;
356#ifdef CONFIG_ARCH_OMAP3
357 struct omap_mcbsp_st_data *st_data; 356 struct omap_mcbsp_st_data *st_data;
358#endif
359 int dma_op_mode; 357 int dma_op_mode;
360 u16 max_tx_thres; 358 u16 max_tx_thres;
361 u16 max_rx_thres; 359 u16 max_rx_thres;
@@ -402,21 +400,11 @@ void omap2_mcbsp1_mux_fsr_src(u8 mux);
402int omap_mcbsp_dma_ch_params(unsigned int id, unsigned int stream); 400int omap_mcbsp_dma_ch_params(unsigned int id, unsigned int stream);
403int omap_mcbsp_dma_reg_params(unsigned int id, unsigned int stream); 401int omap_mcbsp_dma_reg_params(unsigned int id, unsigned int stream);
404 402
405#ifdef CONFIG_ARCH_OMAP3
406/* Sidetone specific API */ 403/* Sidetone specific API */
407int omap_st_set_chgain(unsigned int id, int channel, s16 chgain); 404int omap_st_set_chgain(unsigned int id, int channel, s16 chgain);
408int omap_st_get_chgain(unsigned int id, int channel, s16 *chgain); 405int omap_st_get_chgain(unsigned int id, int channel, s16 *chgain);
409int omap_st_enable(unsigned int id); 406int omap_st_enable(unsigned int id);
410int omap_st_disable(unsigned int id); 407int omap_st_disable(unsigned int id);
411int omap_st_is_enabled(unsigned int id); 408int omap_st_is_enabled(unsigned int id);
412#else
413static inline int omap_st_set_chgain(unsigned int id, int channel,
414 s16 chgain) { return 0; }
415static inline int omap_st_get_chgain(unsigned int id, int channel,
416 s16 *chgain) { return 0; }
417static inline int omap_st_enable(unsigned int id) { return 0; }
418static inline int omap_st_disable(unsigned int id) { return 0; }
419static inline int omap_st_is_enabled(unsigned int id) { return 0; }
420#endif
421 409
422#endif 410#endif
diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c
index e96d747fbd80..f92227f99f86 100644
--- a/arch/arm/plat-omap/mcbsp.c
+++ b/arch/arm/plat-omap/mcbsp.c
@@ -55,7 +55,6 @@ static int omap_mcbsp_read(struct omap_mcbsp *mcbsp, u16 reg, bool from_cache)
55 } 55 }
56} 56}
57 57
58#ifdef CONFIG_ARCH_OMAP3
59static void omap_mcbsp_st_write(struct omap_mcbsp *mcbsp, u16 reg, u32 val) 58static void omap_mcbsp_st_write(struct omap_mcbsp *mcbsp, u16 reg, u32 val)
60{ 59{
61 __raw_writel(val, mcbsp->st_data->io_base_st + reg); 60 __raw_writel(val, mcbsp->st_data->io_base_st + reg);
@@ -65,7 +64,6 @@ static int omap_mcbsp_st_read(struct omap_mcbsp *mcbsp, u16 reg)
65{ 64{
66 return __raw_readl(mcbsp->st_data->io_base_st + reg); 65 return __raw_readl(mcbsp->st_data->io_base_st + reg);
67} 66}
68#endif
69 67
70#define MCBSP_READ(mcbsp, reg) \ 68#define MCBSP_READ(mcbsp, reg) \
71 omap_mcbsp_read(mcbsp, OMAP_MCBSP_REG_##reg, 0) 69 omap_mcbsp_read(mcbsp, OMAP_MCBSP_REG_##reg, 0)
@@ -248,7 +246,6 @@ int omap_mcbsp_dma_reg_params(unsigned int id, unsigned int stream)
248} 246}
249EXPORT_SYMBOL(omap_mcbsp_dma_reg_params); 247EXPORT_SYMBOL(omap_mcbsp_dma_reg_params);
250 248
251#ifdef CONFIG_ARCH_OMAP3
252static void omap_st_on(struct omap_mcbsp *mcbsp) 249static void omap_st_on(struct omap_mcbsp *mcbsp)
253{ 250{
254 unsigned int w; 251 unsigned int w;
@@ -482,11 +479,6 @@ int omap_st_is_enabled(unsigned int id)
482} 479}
483EXPORT_SYMBOL(omap_st_is_enabled); 480EXPORT_SYMBOL(omap_st_is_enabled);
484 481
485#else
486static inline void omap_st_start(struct omap_mcbsp *mcbsp) {}
487static inline void omap_st_stop(struct omap_mcbsp *mcbsp) {}
488#endif
489
490/* 482/*
491 * omap_mcbsp_set_rx_threshold configures the transmit threshold in words. 483 * omap_mcbsp_set_rx_threshold configures the transmit threshold in words.
492 * The threshold parameter is 1 based, and it is converted (threshold - 1) 484 * The threshold parameter is 1 based, and it is converted (threshold - 1)
@@ -802,7 +794,7 @@ void omap_mcbsp_start(unsigned int id, int tx, int rx)
802 } 794 }
803 mcbsp = id_to_mcbsp_ptr(id); 795 mcbsp = id_to_mcbsp_ptr(id);
804 796
805 if (cpu_is_omap34xx()) 797 if (mcbsp->st_data)
806 omap_st_start(mcbsp); 798 omap_st_start(mcbsp);
807 799
808 /* Only enable SRG, if McBSP is master */ 800 /* Only enable SRG, if McBSP is master */
@@ -897,7 +889,7 @@ void omap_mcbsp_stop(unsigned int id, int tx, int rx)
897 MCBSP_WRITE(mcbsp, SPCR2, w & ~(1 << 6)); 889 MCBSP_WRITE(mcbsp, SPCR2, w & ~(1 << 6));
898 } 890 }
899 891
900 if (cpu_is_omap34xx()) 892 if (mcbsp->st_data)
901 omap_st_stop(mcbsp); 893 omap_st_stop(mcbsp);
902} 894}
903EXPORT_SYMBOL(omap_mcbsp_stop); 895EXPORT_SYMBOL(omap_mcbsp_stop);
@@ -1030,7 +1022,6 @@ static const struct attribute_group additional_attr_group = {
1030 .attrs = (struct attribute **)additional_attrs, 1022 .attrs = (struct attribute **)additional_attrs,
1031}; 1023};
1032 1024
1033#ifdef CONFIG_ARCH_OMAP3
1034static ssize_t st_taps_show(struct device *dev, 1025static ssize_t st_taps_show(struct device *dev,
1035 struct device_attribute *attr, char *buf) 1026 struct device_attribute *attr, char *buf)
1036{ 1027{
@@ -1098,10 +1089,9 @@ static const struct attribute_group sidetone_attr_group = {
1098 .attrs = (struct attribute **)sidetone_attrs, 1089 .attrs = (struct attribute **)sidetone_attrs,
1099}; 1090};
1100 1091
1101static int __devinit omap_st_add(struct omap_mcbsp *mcbsp) 1092static int __devinit omap_st_add(struct omap_mcbsp *mcbsp,
1093 struct resource *res)
1102{ 1094{
1103 struct platform_device *pdev;
1104 struct resource *res;
1105 struct omap_mcbsp_st_data *st_data; 1095 struct omap_mcbsp_st_data *st_data;
1106 int err; 1096 int err;
1107 1097
@@ -1111,9 +1101,6 @@ static int __devinit omap_st_add(struct omap_mcbsp *mcbsp)
1111 goto err1; 1101 goto err1;
1112 } 1102 }
1113 1103
1114 pdev = container_of(mcbsp->dev, struct platform_device, dev);
1115
1116 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sidetone");
1117 st_data->io_base_st = ioremap(res->start, resource_size(res)); 1104 st_data->io_base_st = ioremap(res->start, resource_size(res));
1118 if (!st_data->io_base_st) { 1105 if (!st_data->io_base_st) {
1119 err = -ENOMEM; 1106 err = -ENOMEM;
@@ -1140,32 +1127,10 @@ static void __devexit omap_st_remove(struct omap_mcbsp *mcbsp)
1140{ 1127{
1141 struct omap_mcbsp_st_data *st_data = mcbsp->st_data; 1128 struct omap_mcbsp_st_data *st_data = mcbsp->st_data;
1142 1129
1143 if (st_data) { 1130 sysfs_remove_group(&mcbsp->dev->kobj, &sidetone_attr_group);
1144 sysfs_remove_group(&mcbsp->dev->kobj, &sidetone_attr_group); 1131 iounmap(st_data->io_base_st);
1145 iounmap(st_data->io_base_st); 1132 kfree(st_data);
1146 kfree(st_data);
1147 }
1148}
1149
1150static inline void __devinit omap34xx_device_init(struct omap_mcbsp *mcbsp)
1151{
1152 if (cpu_is_omap34xx())
1153 if (mcbsp->id == 2 || mcbsp->id == 3)
1154 if (omap_st_add(mcbsp))
1155 dev_warn(mcbsp->dev,
1156 "Unable to create sidetone controls\n");
1157}
1158
1159static inline void __devexit omap34xx_device_exit(struct omap_mcbsp *mcbsp)
1160{
1161 if (cpu_is_omap34xx())
1162 if (mcbsp->id == 2 || mcbsp->id == 3)
1163 omap_st_remove(mcbsp);
1164} 1133}
1165#else
1166static inline void __devinit omap34xx_device_init(struct omap_mcbsp *mcbsp) {}
1167static inline void __devexit omap34xx_device_exit(struct omap_mcbsp *mcbsp) {}
1168#endif /* CONFIG_ARCH_OMAP3 */
1169 1134
1170/* 1135/*
1171 * McBSP1 and McBSP3 are directly mapped on 1610 and 1510. 1136 * McBSP1 and McBSP3 are directly mapped on 1610 and 1510.
@@ -1291,11 +1256,22 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev)
1291 mcbsp->max_rx_thres = -EINVAL; 1256 mcbsp->max_rx_thres = -EINVAL;
1292 } 1257 }
1293 1258
1294 /* Initialize mcbsp properties for OMAP34XX if needed / applicable */ 1259 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sidetone");
1295 omap34xx_device_init(mcbsp); 1260 if (res) {
1261 ret = omap_st_add(mcbsp, res);
1262 if (ret) {
1263 dev_err(mcbsp->dev,
1264 "Unable to create sidetone controls\n");
1265 goto err_st;
1266 }
1267 }
1296 1268
1297 return 0; 1269 return 0;
1298 1270
1271err_st:
1272 if (mcbsp->pdata->buffer_size)
1273 sysfs_remove_group(&mcbsp->dev->kobj,
1274 &additional_attr_group);
1299err_thres: 1275err_thres:
1300 clk_put(mcbsp->fclk); 1276 clk_put(mcbsp->fclk);
1301err_res: 1277err_res:
@@ -1321,7 +1297,8 @@ static int __devexit omap_mcbsp_remove(struct platform_device *pdev)
1321 sysfs_remove_group(&mcbsp->dev->kobj, 1297 sysfs_remove_group(&mcbsp->dev->kobj,
1322 &additional_attr_group); 1298 &additional_attr_group);
1323 1299
1324 omap34xx_device_exit(mcbsp); 1300 if (mcbsp->st_data)
1301 omap_st_remove(mcbsp);
1325 1302
1326 clk_put(mcbsp->fclk); 1303 clk_put(mcbsp->fclk);
1327 1304