root/drivers/power/reset/rmobile-reset.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. rmobile_reset_handler
  2. rmobile_reset_probe
  3. rmobile_reset_remove

   1 // SPDX-License-Identifier: GPL-2.0
   2 /*
   3  * Renesas R-Mobile Reset Driver
   4  *
   5  * Copyright (C) 2014 Glider bvba
   6  */
   7 
   8 #include <linux/io.h>
   9 #include <linux/module.h>
  10 #include <linux/notifier.h>
  11 #include <linux/of_address.h>
  12 #include <linux/platform_device.h>
  13 #include <linux/printk.h>
  14 #include <linux/reboot.h>
  15 
  16 /* SYSC Register Bank 2 */
  17 #define RESCNT2         0x20            /* Reset Control Register 2 */
  18 
  19 /* Reset Control Register 2 */
  20 #define RESCNT2_PRES    0x80000000      /* Soft power-on reset */
  21 
  22 static void __iomem *sysc_base2;
  23 
  24 static int rmobile_reset_handler(struct notifier_block *this,
  25                                  unsigned long mode, void *cmd)
  26 {
  27         pr_debug("%s %lu\n", __func__, mode);
  28 
  29         /* Let's assume we have acquired the HPB semaphore */
  30         writel(RESCNT2_PRES, sysc_base2 + RESCNT2);
  31 
  32         return NOTIFY_DONE;
  33 }
  34 
  35 static struct notifier_block rmobile_reset_nb = {
  36         .notifier_call = rmobile_reset_handler,
  37         .priority = 192,
  38 };
  39 
  40 static int rmobile_reset_probe(struct platform_device *pdev)
  41 {
  42         int error;
  43 
  44         sysc_base2 = of_iomap(pdev->dev.of_node, 1);
  45         if (!sysc_base2)
  46                 return -ENODEV;
  47 
  48         error = register_restart_handler(&rmobile_reset_nb);
  49         if (error) {
  50                 dev_err(&pdev->dev,
  51                         "cannot register restart handler (err=%d)\n", error);
  52                 goto fail_unmap;
  53         }
  54 
  55         return 0;
  56 
  57 fail_unmap:
  58         iounmap(sysc_base2);
  59         return error;
  60 }
  61 
  62 static int rmobile_reset_remove(struct platform_device *pdev)
  63 {
  64         unregister_restart_handler(&rmobile_reset_nb);
  65         iounmap(sysc_base2);
  66         return 0;
  67 }
  68 
  69 static const struct of_device_id rmobile_reset_of_match[] = {
  70         { .compatible = "renesas,sysc-rmobile", },
  71         { /* sentinel */ }
  72 };
  73 MODULE_DEVICE_TABLE(of, rmobile_reset_of_match);
  74 
  75 static struct platform_driver rmobile_reset_driver = {
  76         .probe = rmobile_reset_probe,
  77         .remove = rmobile_reset_remove,
  78         .driver = {
  79                 .name = "rmobile_reset",
  80                 .of_match_table = rmobile_reset_of_match,
  81         },
  82 };
  83 
  84 module_platform_driver(rmobile_reset_driver);
  85 
  86 MODULE_DESCRIPTION("Renesas R-Mobile Reset Driver");
  87 MODULE_AUTHOR("Geert Uytterhoeven <geert+renesas@glider.be>");
  88 MODULE_LICENSE("GPL v2");

/* [<][>][^][v][top][bottom][index][help] */