|
@@ -728,3 +728,66 @@ unsigned short get_gpio_dir(unsigned gpio)
|
|
|
}
|
|
|
EXPORT_SYMBOL(get_gpio_dir);
|
|
|
|
|
|
+#endif /* CONFIG_BF54x || CONFIG_BF60x */
|
|
|
+
|
|
|
+/***********************************************************
|
|
|
+*
|
|
|
+* FUNCTIONS: Blackfin Peripheral Resource Allocation
|
|
|
+* and PortMux Setup
|
|
|
+*
|
|
|
+* INPUTS/OUTPUTS:
|
|
|
+* per Peripheral Identifier
|
|
|
+* label String
|
|
|
+*
|
|
|
+* DESCRIPTION: Blackfin Peripheral Resource Allocation and Setup API
|
|
|
+*
|
|
|
+* CAUTION:
|
|
|
+*************************************************************
|
|
|
+* MODIFICATION HISTORY :
|
|
|
+**************************************************************/
|
|
|
+
|
|
|
+int peripheral_request(unsigned short per, const char *label)
|
|
|
+{
|
|
|
+ unsigned long flags;
|
|
|
+ unsigned short ident = P_IDENT(per);
|
|
|
+
|
|
|
+ /*
|
|
|
+ * Don't cares are pins with only one dedicated function
|
|
|
+ */
|
|
|
+
|
|
|
+ if (per & P_DONTCARE)
|
|
|
+ return 0;
|
|
|
+
|
|
|
+ if (!(per & P_DEFINED))
|
|
|
+ return -ENODEV;
|
|
|
+
|
|
|
+ BUG_ON(ident >= MAX_RESOURCES);
|
|
|
+
|
|
|
+ flags = hard_local_irq_save();
|
|
|
+
|
|
|
+ /* If a pin can be muxed as either GPIO or peripheral, make
|
|
|
+ * sure it is not already a GPIO pin when we request it.
|
|
|
+ */
|
|
|
+ if (unlikely(!check_gpio(ident) && is_reserved(gpio, ident, 1))) {
|
|
|
+ if (system_state == SYSTEM_BOOTING)
|
|
|
+ dump_stack();
|
|
|
+ printk(KERN_ERR
|
|
|
+ "%s: Peripheral %d is already reserved as GPIO by %s !\n",
|
|
|
+ __func__, ident, get_label(ident));
|
|
|
+ hard_local_irq_restore(flags);
|
|
|
+ return -EBUSY;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (unlikely(is_reserved(peri, ident, 1))) {
|
|
|
+
|
|
|
+ /*
|
|
|
+ * Pin functions like AMC address strobes my
|
|
|
+ * be requested and used by several drivers
|
|
|
+ */
|
|
|
+
|
|
|
+#if defined(CONFIG_BF54x) || defined(CONFIG_BF60x)
|
|
|
+ if (!((per & P_MAYSHARE) && get_portmux(per) == P_FUNCT2MUX(per))) {
|
|
|
+#else
|
|
|
+ if (!(per & P_MAYSHARE)) {
|
|
|
+#endif
|
|
|
+ /*
|