1 --- a/drivers/misc/Makefile
2 +++ b/drivers/misc/Makefile
3 @@ -57,6 +57,7 @@ obj-$(CONFIG_CXL_BASE) += cxl/
4 obj-$(CONFIG_ASPEED_LPC_CTRL) += aspeed-lpc-ctrl.o
5 obj-$(CONFIG_ASPEED_LPC_SNOOP) += aspeed-lpc-snoop.o
6 obj-$(CONFIG_PCI_ENDPOINT_TEST) += pci_endpoint_test.o
7 +obj-$(CONFIG_SOC_MT7620) += linkit.o
9 lkdtm-$(CONFIG_LKDTM) += lkdtm_core.o
10 lkdtm-$(CONFIG_LKDTM) += lkdtm_bugs.o
12 +++ b/drivers/misc/linkit.c
15 + * This program is free software; you can redistribute it and/or modify
16 + * it under the terms of the GNU General Public License version 2 as
17 + * publishhed by the Free Software Foundation.
19 + * Copyright (C) 2015 John Crispin <blogic@openwrt.org>
22 +#include <linux/module.h>
23 +#include <linux/platform_device.h>
24 +#include <linux/of.h>
25 +#include <linux/mtd/mtd.h>
26 +#include <linux/gpio.h>
28 +#define LINKIT_LATCH_GPIO 11
30 +struct linkit_hw_data {
35 +static void sanify_string(char *s)
39 + for (i = 0; i < 15; i++)
45 +static int linkit_probe(struct platform_device *pdev)
47 + struct linkit_hw_data hw;
48 + struct mtd_info *mtd;
52 + mtd = get_mtd_device_nm("factory");
54 + return PTR_ERR(mtd);
56 + ret = mtd_read(mtd, 0x400, sizeof(hw), &retlen, (u_char *) &hw);
57 + put_mtd_device(mtd);
59 + sanify_string(hw.board);
60 + sanify_string(hw.rev);
62 + dev_info(&pdev->dev, "Version : %s\n", hw.board);
63 + dev_info(&pdev->dev, "Revision : %s\n", hw.rev);
65 + if (!strcmp(hw.board, "LINKITS7688")) {
66 + dev_info(&pdev->dev, "setting up bootstrap latch\n");
68 + if (devm_gpio_request(&pdev->dev, LINKIT_LATCH_GPIO, "bootstrap")) {
69 + dev_err(&pdev->dev, "failed to setup bootstrap gpio\n");
72 + gpio_direction_output(LINKIT_LATCH_GPIO, 0);
78 +static const struct of_device_id linkit_match[] = {
79 + { .compatible = "mediatek,linkit" },
82 +MODULE_DEVICE_TABLE(of, linkit_match);
84 +static struct platform_driver linkit_driver = {
85 + .probe = linkit_probe,
87 + .name = "mtk-linkit",
88 + .owner = THIS_MODULE,
89 + .of_match_table = linkit_match,
93 +int __init linkit_init(void)
95 + return platform_driver_register(&linkit_driver);
97 +late_initcall_sync(linkit_init);