diff options
Diffstat (limited to 'arch/arm/plat-omap/mcbsp.c')
-rw-r--r-- | arch/arm/plat-omap/mcbsp.c | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c index 081f2eace92d..0bbc912e548d 100644 --- a/arch/arm/plat-omap/mcbsp.c +++ b/arch/arm/plat-omap/mcbsp.c | |||
@@ -246,6 +246,42 @@ void omap_mcbsp_set_rx_threshold(unsigned int id, u16 threshold) | |||
246 | OMAP_MCBSP_WRITE(io_base, THRSH1, threshold); | 246 | OMAP_MCBSP_WRITE(io_base, THRSH1, threshold); |
247 | } | 247 | } |
248 | EXPORT_SYMBOL(omap_mcbsp_set_rx_threshold); | 248 | EXPORT_SYMBOL(omap_mcbsp_set_rx_threshold); |
249 | |||
250 | /* | ||
251 | * omap_mcbsp_get_max_tx_thres just return the current configured | ||
252 | * maximum threshold for transmission | ||
253 | */ | ||
254 | u16 omap_mcbsp_get_max_tx_threshold(unsigned int id) | ||
255 | { | ||
256 | struct omap_mcbsp *mcbsp; | ||
257 | |||
258 | if (!omap_mcbsp_check_valid_id(id)) { | ||
259 | printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); | ||
260 | return -ENODEV; | ||
261 | } | ||
262 | mcbsp = id_to_mcbsp_ptr(id); | ||
263 | |||
264 | return mcbsp->max_tx_thres; | ||
265 | } | ||
266 | EXPORT_SYMBOL(omap_mcbsp_get_max_tx_threshold); | ||
267 | |||
268 | /* | ||
269 | * omap_mcbsp_get_max_rx_thres just return the current configured | ||
270 | * maximum threshold for reception | ||
271 | */ | ||
272 | u16 omap_mcbsp_get_max_rx_threshold(unsigned int id) | ||
273 | { | ||
274 | struct omap_mcbsp *mcbsp; | ||
275 | |||
276 | if (!omap_mcbsp_check_valid_id(id)) { | ||
277 | printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); | ||
278 | return -ENODEV; | ||
279 | } | ||
280 | mcbsp = id_to_mcbsp_ptr(id); | ||
281 | |||
282 | return mcbsp->max_rx_thres; | ||
283 | } | ||
284 | EXPORT_SYMBOL(omap_mcbsp_get_max_rx_threshold); | ||
249 | #endif | 285 | #endif |
250 | 286 | ||
251 | /* | 287 | /* |
@@ -1005,6 +1041,86 @@ void omap_mcbsp_set_spi_mode(unsigned int id, | |||
1005 | } | 1041 | } |
1006 | EXPORT_SYMBOL(omap_mcbsp_set_spi_mode); | 1042 | EXPORT_SYMBOL(omap_mcbsp_set_spi_mode); |
1007 | 1043 | ||
1044 | #ifdef CONFIG_ARCH_OMAP34XX | ||
1045 | #define max_thres(m) (mcbsp->pdata->buffer_size) | ||
1046 | #define valid_threshold(m, val) ((val) <= max_thres(m)) | ||
1047 | #define THRESHOLD_PROP_BUILDER(prop) \ | ||
1048 | static ssize_t prop##_show(struct device *dev, \ | ||
1049 | struct device_attribute *attr, char *buf) \ | ||
1050 | { \ | ||
1051 | struct omap_mcbsp *mcbsp = dev_get_drvdata(dev); \ | ||
1052 | \ | ||
1053 | return sprintf(buf, "%u\n", mcbsp->prop); \ | ||
1054 | } \ | ||
1055 | \ | ||
1056 | static ssize_t prop##_store(struct device *dev, \ | ||
1057 | struct device_attribute *attr, \ | ||
1058 | const char *buf, size_t size) \ | ||
1059 | { \ | ||
1060 | struct omap_mcbsp *mcbsp = dev_get_drvdata(dev); \ | ||
1061 | unsigned long val; \ | ||
1062 | int status; \ | ||
1063 | \ | ||
1064 | status = strict_strtoul(buf, 0, &val); \ | ||
1065 | if (status) \ | ||
1066 | return status; \ | ||
1067 | \ | ||
1068 | if (!valid_threshold(mcbsp, val)) \ | ||
1069 | return -EDOM; \ | ||
1070 | \ | ||
1071 | mcbsp->prop = val; \ | ||
1072 | return size; \ | ||
1073 | } \ | ||
1074 | \ | ||
1075 | static DEVICE_ATTR(prop, 0644, prop##_show, prop##_store); | ||
1076 | |||
1077 | THRESHOLD_PROP_BUILDER(max_tx_thres); | ||
1078 | THRESHOLD_PROP_BUILDER(max_rx_thres); | ||
1079 | |||
1080 | static const struct attribute *threshold_attrs[] = { | ||
1081 | &dev_attr_max_tx_thres.attr, | ||
1082 | &dev_attr_max_rx_thres.attr, | ||
1083 | NULL, | ||
1084 | }; | ||
1085 | |||
1086 | static const struct attribute_group threshold_attr_group = { | ||
1087 | .attrs = (struct attribute **)threshold_attrs, | ||
1088 | }; | ||
1089 | |||
1090 | static inline int __devinit omap_thres_add(struct device *dev) | ||
1091 | { | ||
1092 | return sysfs_create_group(&dev->kobj, &threshold_attr_group); | ||
1093 | } | ||
1094 | |||
1095 | static inline void __devexit omap_thres_remove(struct device *dev) | ||
1096 | { | ||
1097 | sysfs_remove_group(&dev->kobj, &threshold_attr_group); | ||
1098 | } | ||
1099 | |||
1100 | static inline void __devinit omap34xx_device_init(struct omap_mcbsp *mcbsp) | ||
1101 | { | ||
1102 | if (cpu_is_omap34xx()) { | ||
1103 | mcbsp->max_tx_thres = max_thres(mcbsp); | ||
1104 | mcbsp->max_rx_thres = max_thres(mcbsp); | ||
1105 | if (omap_thres_add(mcbsp->dev)) | ||
1106 | dev_warn(mcbsp->dev, | ||
1107 | "Unable to create threshold controls\n"); | ||
1108 | } else { | ||
1109 | mcbsp->max_tx_thres = -EINVAL; | ||
1110 | mcbsp->max_rx_thres = -EINVAL; | ||
1111 | } | ||
1112 | } | ||
1113 | |||
1114 | static inline void __devexit omap34xx_device_exit(struct omap_mcbsp *mcbsp) | ||
1115 | { | ||
1116 | if (cpu_is_omap34xx()) | ||
1117 | omap_thres_remove(mcbsp->dev); | ||
1118 | } | ||
1119 | #else | ||
1120 | static inline void __devinit omap34xx_device_init(struct omap_mcbsp *mcbsp) {} | ||
1121 | static inline void __devexit omap34xx_device_exit(struct omap_mcbsp *mcbsp) {} | ||
1122 | #endif /* CONFIG_ARCH_OMAP34XX */ | ||
1123 | |||
1008 | /* | 1124 | /* |
1009 | * McBSP1 and McBSP3 are directly mapped on 1610 and 1510. | 1125 | * McBSP1 and McBSP3 are directly mapped on 1610 and 1510. |
1010 | * 730 has only 2 McBSP, and both of them are MPU peripherals. | 1126 | * 730 has only 2 McBSP, and both of them are MPU peripherals. |
@@ -1075,6 +1191,10 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev) | |||
1075 | mcbsp->dev = &pdev->dev; | 1191 | mcbsp->dev = &pdev->dev; |
1076 | mcbsp_ptr[id] = mcbsp; | 1192 | mcbsp_ptr[id] = mcbsp; |
1077 | platform_set_drvdata(pdev, mcbsp); | 1193 | platform_set_drvdata(pdev, mcbsp); |
1194 | |||
1195 | /* Initialize mcbsp properties for OMAP34XX if needed / applicable */ | ||
1196 | omap34xx_device_init(mcbsp); | ||
1197 | |||
1078 | return 0; | 1198 | return 0; |
1079 | 1199 | ||
1080 | err_fclk: | 1200 | err_fclk: |
@@ -1098,6 +1218,8 @@ static int __devexit omap_mcbsp_remove(struct platform_device *pdev) | |||
1098 | mcbsp->pdata->ops->free) | 1218 | mcbsp->pdata->ops->free) |
1099 | mcbsp->pdata->ops->free(mcbsp->id); | 1219 | mcbsp->pdata->ops->free(mcbsp->id); |
1100 | 1220 | ||
1221 | omap34xx_device_exit(mcbsp); | ||
1222 | |||
1101 | clk_disable(mcbsp->fclk); | 1223 | clk_disable(mcbsp->fclk); |
1102 | clk_disable(mcbsp->iclk); | 1224 | clk_disable(mcbsp->iclk); |
1103 | clk_put(mcbsp->fclk); | 1225 | clk_put(mcbsp->fclk); |