1 --- a/drivers/misc/Makefile
2 +++ b/drivers/misc/Makefile
3 @@ -56,3 +56,4 @@ obj-$(CONFIG_GENWQE) += genwqe/
4 obj-$(CONFIG_ECHO) += echo/
5 obj-$(CONFIG_VEXPRESS_SYSCFG) += vexpress-syscfg.o
6 obj-$(CONFIG_CXL_BASE) += cxl/
7 +obj-$(CONFIG_SOC_MT7620) += linkit.o
9 +++ b/drivers/misc/linkit.c
12 + * This program is free software; you can redistribute it and/or modify
13 + * it under the terms of the GNU General Public License version 2 as
14 + * publishhed by the Free Software Foundation.
16 + * Copyright (C) 2015 John Crispin <blogic@openwrt.org>
19 +#include <linux/module.h>
20 +#include <linux/platform_device.h>
21 +#include <linux/of.h>
22 +#include <linux/mtd/mtd.h>
23 +#include <linux/gpio.h>
25 +#define LINKIT_LATCH_GPIO 11
27 +struct linkit_hw_data {
32 +static void sanify_string(char *s)
36 + for (i = 0; i < 15; i++)
42 +static int linkit_probe(struct platform_device *pdev)
44 + struct linkit_hw_data hw;
45 + struct mtd_info *mtd;
49 + mtd = get_mtd_device_nm("factory");
51 + return PTR_ERR(mtd);
53 + ret = mtd_read(mtd, 0x400, sizeof(hw), &retlen, (u_char *) &hw);
54 + put_mtd_device(mtd);
56 + sanify_string(hw.board);
57 + sanify_string(hw.rev);
59 + dev_info(&pdev->dev, "Version : %s\n", hw.board);
60 + dev_info(&pdev->dev, "Revision : %s\n", hw.rev);
62 + if (!strcmp(hw.board, "LINKITS7688")) {
63 + dev_info(&pdev->dev, "setting up bootstrap latch\n");
65 + if (devm_gpio_request(&pdev->dev, LINKIT_LATCH_GPIO, "bootstrap")) {
66 + dev_err(&pdev->dev, "failed to setup bootstrap gpio\n");
69 + gpio_direction_output(LINKIT_LATCH_GPIO, 0);
75 +static const struct of_device_id linkit_match[] = {
76 + { .compatible = "mediatek,linkit" },
79 +MODULE_DEVICE_TABLE(of, linkit_match);
81 +static struct platform_driver linkit_driver = {
82 + .probe = linkit_probe,
84 + .name = "mtk-linkit",
85 + .owner = THIS_MODULE,
86 + .of_match_table = linkit_match,
90 +int __init linkit_init(void)
92 + return platform_driver_register(&linkit_driver);
94 +late_initcall_sync(linkit_init);