|
@@ -791,3 +791,103 @@ int peripheral_request(unsigned short per, const char *label)
|
|
|
if (!(per & P_MAYSHARE)) {
|
|
|
#endif
|
|
|
/*
|
|
|
+ * Allow that the identical pin function can
|
|
|
+ * be requested from the same driver twice
|
|
|
+ */
|
|
|
+
|
|
|
+ if (cmp_label(ident, label) == 0)
|
|
|
+ goto anyway;
|
|
|
+
|
|
|
+ if (system_state == SYSTEM_BOOTING)
|
|
|
+ dump_stack();
|
|
|
+ printk(KERN_ERR
|
|
|
+ "%s: Peripheral %d function %d is already reserved by %s !\n",
|
|
|
+ __func__, ident, P_FUNCT2MUX(per), get_label(ident));
|
|
|
+ hard_local_irq_restore(flags);
|
|
|
+ return -EBUSY;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (unlikely(portmux_group_check(per))) {
|
|
|
+ hard_local_irq_restore(flags);
|
|
|
+ return -EBUSY;
|
|
|
+ }
|
|
|
+ anyway:
|
|
|
+ reserve(peri, ident);
|
|
|
+
|
|
|
+ portmux_setup(per);
|
|
|
+ port_setup(ident, PERIPHERAL_USAGE);
|
|
|
+
|
|
|
+ hard_local_irq_restore(flags);
|
|
|
+ set_label(ident, label);
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+EXPORT_SYMBOL(peripheral_request);
|
|
|
+
|
|
|
+int peripheral_request_list(const unsigned short per[], const char *label)
|
|
|
+{
|
|
|
+ u16 cnt;
|
|
|
+ int ret;
|
|
|
+
|
|
|
+ for (cnt = 0; per[cnt] != 0; cnt++) {
|
|
|
+
|
|
|
+ ret = peripheral_request(per[cnt], label);
|
|
|
+
|
|
|
+ if (ret < 0) {
|
|
|
+ for ( ; cnt > 0; cnt--)
|
|
|
+ peripheral_free(per[cnt - 1]);
|
|
|
+
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+EXPORT_SYMBOL(peripheral_request_list);
|
|
|
+
|
|
|
+void peripheral_free(unsigned short per)
|
|
|
+{
|
|
|
+ unsigned long flags;
|
|
|
+ unsigned short ident = P_IDENT(per);
|
|
|
+
|
|
|
+ if (per & P_DONTCARE)
|
|
|
+ return;
|
|
|
+
|
|
|
+ if (!(per & P_DEFINED))
|
|
|
+ return;
|
|
|
+
|
|
|
+ flags = hard_local_irq_save();
|
|
|
+
|
|
|
+ if (unlikely(!is_reserved(peri, ident, 0))) {
|
|
|
+ hard_local_irq_restore(flags);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!(per & P_MAYSHARE))
|
|
|
+ port_setup(ident, GPIO_USAGE);
|
|
|
+
|
|
|
+ unreserve(peri, ident);
|
|
|
+
|
|
|
+ set_label(ident, "free");
|
|
|
+
|
|
|
+ hard_local_irq_restore(flags);
|
|
|
+}
|
|
|
+EXPORT_SYMBOL(peripheral_free);
|
|
|
+
|
|
|
+void peripheral_free_list(const unsigned short per[])
|
|
|
+{
|
|
|
+ u16 cnt;
|
|
|
+ for (cnt = 0; per[cnt] != 0; cnt++)
|
|
|
+ peripheral_free(per[cnt]);
|
|
|
+}
|
|
|
+EXPORT_SYMBOL(peripheral_free_list);
|
|
|
+
|
|
|
+/***********************************************************
|
|
|
+*
|
|
|
+* FUNCTIONS: Blackfin GPIO Driver
|
|
|
+*
|
|
|
+* INPUTS/OUTPUTS:
|
|
|
+* gpio PIO Number between 0 and MAX_BLACKFIN_GPIOS
|
|
|
+* label String
|
|
|
+*
|