~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/mips/pic32/pic32mzda/config.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*
  3  * Purna Chandra Mandal, purna.mandal@microchip.com
  4  * Copyright (C) 2015 Microchip Technology Inc.  All rights reserved.
  5  */
  6 #include <linux/init.h>
  7 #include <linux/io.h>
  8 #include <linux/spinlock.h>
  9 
 10 #include <asm/mach-pic32/pic32.h>
 11 
 12 #include "pic32mzda.h"
 13 
 14 #define PIC32_CFGCON    0x0000
 15 #define PIC32_DEVID     0x0020
 16 #define PIC32_SYSKEY    0x0030
 17 #define PIC32_CFGEBIA   0x00c0
 18 #define PIC32_CFGEBIC   0x00d0
 19 #define PIC32_CFGCON2   0x00f0
 20 #define PIC32_RCON      0x1240
 21 
 22 static void __iomem *pic32_conf_base;
 23 static DEFINE_SPINLOCK(config_lock);
 24 static u32 pic32_reset_status;
 25 
 26 static u32 pic32_conf_get_reg_field(u32 offset, u32 rshift, u32 mask)
 27 {
 28         u32 v;
 29 
 30         v = readl(pic32_conf_base + offset);
 31         v >>= rshift;
 32         v &= mask;
 33 
 34         return v;
 35 }
 36 
 37 static u32 pic32_conf_modify_atomic(u32 offset, u32 mask, u32 set)
 38 {
 39         u32 v;
 40         unsigned long flags;
 41 
 42         spin_lock_irqsave(&config_lock, flags);
 43         v = readl(pic32_conf_base + offset);
 44         v &= ~mask;
 45         v |= (set & mask);
 46         writel(v, pic32_conf_base + offset);
 47         spin_unlock_irqrestore(&config_lock, flags);
 48 
 49         return 0;
 50 }
 51 
 52 int pic32_enable_lcd(void)
 53 {
 54         return pic32_conf_modify_atomic(PIC32_CFGCON2, BIT(31), BIT(31));
 55 }
 56 
 57 int pic32_disable_lcd(void)
 58 {
 59         return pic32_conf_modify_atomic(PIC32_CFGCON2, BIT(31), 0);
 60 }
 61 
 62 int pic32_set_lcd_mode(int mode)
 63 {
 64         u32 mask = mode ? BIT(30) : 0;
 65 
 66         return pic32_conf_modify_atomic(PIC32_CFGCON2, BIT(30), mask);
 67 }
 68 
 69 int pic32_set_sdhci_adma_fifo_threshold(u32 rthrsh, u32 wthrsh)
 70 {
 71         u32 clr, set;
 72 
 73         clr = (0x3ff << 4) | (0x3ff << 16);
 74         set = (rthrsh << 4) | (wthrsh << 16);
 75         return pic32_conf_modify_atomic(PIC32_CFGCON2, clr, set);
 76 }
 77 
 78 void pic32_syskey_unlock_debug(const char *func, const ulong line)
 79 {
 80         void __iomem *syskey = pic32_conf_base + PIC32_SYSKEY;
 81 
 82         pr_debug("%s: called from %s:%lu\n", __func__, func, line);
 83         writel(0x00000000, syskey);
 84         writel(0xAA996655, syskey);
 85         writel(0x556699AA, syskey);
 86 }
 87 
 88 static u32 pic32_get_device_id(void)
 89 {
 90         return pic32_conf_get_reg_field(PIC32_DEVID, 0, 0x0fffffff);
 91 }
 92 
 93 static u32 pic32_get_device_version(void)
 94 {
 95         return pic32_conf_get_reg_field(PIC32_DEVID, 28, 0xf);
 96 }
 97 
 98 u32 pic32_get_boot_status(void)
 99 {
100         return pic32_reset_status;
101 }
102 EXPORT_SYMBOL(pic32_get_boot_status);
103 
104 void __init pic32_config_init(void)
105 {
106         pic32_conf_base = ioremap(PIC32_BASE_CONFIG, 0x110);
107         if (!pic32_conf_base)
108                 panic("pic32: config base not mapped");
109 
110         /* Boot Status */
111         pic32_reset_status = readl(pic32_conf_base + PIC32_RCON);
112         writel(-1, PIC32_CLR(pic32_conf_base + PIC32_RCON));
113 
114         /* Device Information */
115         pr_info("Device Id: 0x%08x, Device Ver: 0x%04x\n",
116                 pic32_get_device_id(),
117                 pic32_get_device_version());
118 }
119 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php