Browse Source

waterDataDiscreteRateMining memoryOperation.c 袁明明 commit at 2021-02-04

袁明明 4 năm trước cách đây
mục cha
commit
f533ebeed9

+ 86 - 0
waterDataDiscreteRateMining/dataSharedMemory/memoryOperation.c

@@ -891,3 +891,89 @@ EXPORT_SYMBOL(peripheral_free_list);
 * gpio	PIO Number between 0 and MAX_BLACKFIN_GPIOS
 * label	String
 *
+* DESCRIPTION: Blackfin GPIO Driver API
+*
+* CAUTION:
+*************************************************************
+* MODIFICATION HISTORY :
+**************************************************************/
+
+int bfin_gpio_request(unsigned gpio, const char *label)
+{
+	unsigned long flags;
+
+	if (check_gpio(gpio) < 0)
+		return -EINVAL;
+
+	flags = hard_local_irq_save();
+
+	/*
+	 * Allow that the identical GPIO can
+	 * be requested from the same driver twice
+	 * Do nothing and return -
+	 */
+
+	if (cmp_label(gpio, label) == 0) {
+		hard_local_irq_restore(flags);
+		return 0;
+	}
+
+	if (unlikely(is_reserved(gpio, gpio, 1))) {
+		if (system_state == SYSTEM_BOOTING)
+			dump_stack();
+		printk(KERN_ERR "bfin-gpio: GPIO %d is already reserved by %s !\n",
+		       gpio, get_label(gpio));
+		hard_local_irq_restore(flags);
+		return -EBUSY;
+	}
+	if (unlikely(is_reserved(peri, gpio, 1))) {
+		if (system_state == SYSTEM_BOOTING)
+			dump_stack();
+		printk(KERN_ERR
+		       "bfin-gpio: GPIO %d is already reserved as Peripheral by %s !\n",
+		       gpio, get_label(gpio));
+		hard_local_irq_restore(flags);
+		return -EBUSY;
+	}
+	if (unlikely(is_reserved(gpio_irq, gpio, 1))) {
+		printk(KERN_NOTICE "bfin-gpio: GPIO %d is already reserved as gpio-irq!"
+		       " (Documentation/blackfin/bfin-gpio-notes.txt)\n", gpio);
+	}
+#if !(defined(CONFIG_BF54x) || defined(CONFIG_BF60x))
+	else {	/* Reset POLAR setting when acquiring a gpio for the first time */
+		set_gpio_polar(gpio, 0);
+	}
+#endif
+
+	reserve(gpio, gpio);
+	set_label(gpio, label);
+
+	hard_local_irq_restore(flags);
+
+	port_setup(gpio, GPIO_USAGE);
+
+	return 0;
+}
+EXPORT_SYMBOL(bfin_gpio_request);
+
+void bfin_gpio_free(unsigned gpio)
+{
+	unsigned long flags;
+
+	if (check_gpio(gpio) < 0)
+		return;
+
+	might_sleep();
+
+	flags = hard_local_irq_save();
+
+	if (unlikely(!is_reserved(gpio, gpio, 0))) {
+		if (system_state == SYSTEM_BOOTING)
+			dump_stack();
+		gpio_error(gpio);
+		hard_local_irq_restore(flags);
+		return;
+	}
+
+	unreserve(gpio, gpio);
+