mirror of https://github.com/OpenIPC/firmware.git
Add ingenic-opensdk package
parent
6995e552e4
commit
2a660ac695
|
@ -1,6 +1,6 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# openhisilicon
|
# hisilicon-opensdk
|
||||||
#
|
#
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
config BR2_PACKAGE_INGENIC_OPENSDK
|
||||||
|
bool "ingenic-opensdk"
|
||||||
|
default n
|
||||||
|
depends on BR2_LINUX_KERNEL
|
||||||
|
help
|
||||||
|
Opensource Ingenic SoCs SDK
|
||||||
|
|
||||||
|
comment "INGENIC_OPENSDK needs a Linux kernel to be built"
|
||||||
|
depends on !BR2_LINUX_KERNEL
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# ingenic-opensdk
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
INGENIC_OPENSDK_LICENSE = GPL-3.0
|
||||||
|
INGENIC_OPENSDK_LICENSE_FILES = LICENSE
|
||||||
|
|
||||||
|
FAMILY = $(shell grep "/board/" $(BR2_CONFIG) | head -1 | cut -d "/" -f 3)
|
||||||
|
|
||||||
|
|
||||||
|
define INGENIC_OPENSDK_EXTRACT_CMDS
|
||||||
|
cp $(BR2_EXTERNAL_INGENIC_PATH)/package/ingenic-opensdk/src/kernel/* $(@D)/
|
||||||
|
endef
|
||||||
|
|
||||||
|
INGENIC_OPENSDK_MODULE_MAKE_OPTS = \
|
||||||
|
>CONFIG_GPIO=m \
|
||||||
|
KVER=$(LINUX_VERSION_PROBED) \
|
||||||
|
KSRC=$(LINUX_DIR)
|
||||||
|
|
||||||
|
$(eval $(kernel-module))
|
||||||
|
$(eval $(generic-package))
|
|
@ -0,0 +1,20 @@
|
||||||
|
CROSS_COMPILE ?= mips-linux-gnu-
|
||||||
|
|
||||||
|
ifeq (${ISVP_ENV_KERNEL_DIR}, )
|
||||||
|
ISVP_ENV_KERNEL_DIR = ../../../kernel
|
||||||
|
endif
|
||||||
|
|
||||||
|
KDIR := ${ISVP_ENV_KERNEL_DIR}
|
||||||
|
MODULE_NAME := gpio
|
||||||
|
|
||||||
|
all: modules
|
||||||
|
|
||||||
|
.PHONY: modules clean
|
||||||
|
|
||||||
|
obj-m := $(MODULE_NAME).o
|
||||||
|
|
||||||
|
modules:
|
||||||
|
@$(MAKE) -C $(KDIR) M=$(shell pwd) $@
|
||||||
|
clean:
|
||||||
|
@rm -rf *.o *~ .depend .*.cmd *.mod.c .tmp_versions *.ko *.symvers modules.order
|
||||||
|
@rm -f gpio
|
|
@ -0,0 +1,78 @@
|
||||||
|
#include <jz_proc.h>
|
||||||
|
#include <linux/proc_fs.h>
|
||||||
|
#include <linux/gpio.h>
|
||||||
|
#include <linux/init.h>
|
||||||
|
#include <linux/kernel.h>
|
||||||
|
#include <linux/module.h>
|
||||||
|
|
||||||
|
|
||||||
|
MODULE_LICENSE("GPL");
|
||||||
|
MODULE_AUTHOR("OpenIPC");
|
||||||
|
MODULE_DESCRIPTION("Ingenic GPIO Claimer");
|
||||||
|
|
||||||
|
static struct proc_dir_entry *claim_proc;
|
||||||
|
|
||||||
|
int claim_gpio(int gpio) {
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
pr_debug("GPIO[%i] Requesting...\n", gpio);
|
||||||
|
|
||||||
|
if (!gpio_is_valid(gpio)) {
|
||||||
|
pr_err("GPIO[%i] is not valid\n", gpio);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gpio_request(gpio, 0) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
pr_debug("GPIO[%i] Setting direction...\n", gpio);
|
||||||
|
gpio_direction_output(gpio, 0);
|
||||||
|
pr_debug("GPIO[%i] Exporting...\n", gpio);
|
||||||
|
gpio_export(gpio, true);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ssize_t claim_proc_write(struct file *filp, const char *buf, size_t len,
|
||||||
|
loff_t *off) {
|
||||||
|
int ret = 0;
|
||||||
|
char cmd[4] = {0};
|
||||||
|
uint32_t addr, data, datalen;
|
||||||
|
|
||||||
|
if (len > 4) {
|
||||||
|
return -EFAULT;
|
||||||
|
}
|
||||||
|
if (copy_from_user(cmd, buf, len)) {
|
||||||
|
return -EFAULT;
|
||||||
|
}
|
||||||
|
int gpio = simple_strtoul(cmd, NULL, 0);
|
||||||
|
ret = claim_gpio(gpio);
|
||||||
|
if (ret) {
|
||||||
|
pr_err("GPIO[%i] Error %i \n", gpio, ret);
|
||||||
|
return -EFAULT;
|
||||||
|
} else {
|
||||||
|
pr_debug("GPIO[%i] Claiming...\n", gpio);
|
||||||
|
}
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct file_operations claim_proc_fops = {
|
||||||
|
.owner = THIS_MODULE,
|
||||||
|
.write = claim_proc_write,
|
||||||
|
};
|
||||||
|
|
||||||
|
static __init int init_claim(void) {
|
||||||
|
claim_proc = proc_mkdir("jz/claim", 0);
|
||||||
|
if (!claim_proc) {
|
||||||
|
printk("err: jz_proc_mkdir failed\n");
|
||||||
|
}
|
||||||
|
proc_create_data("gpio", S_IRUGO, claim_proc, &claim_proc_fops, NULL);
|
||||||
|
printk("Ingenic GPIO claim module (c) OpenIPC.org\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static __exit void exit_claim(void) { proc_remove(claim_proc); }
|
||||||
|
|
||||||
|
module_init(init_claim);
|
||||||
|
module_exit(exit_claim);
|
Binary file not shown.
Loading…
Reference in New Issue