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

TOMOYO Linux Cross Reference
Linux/arch/mips/sgi-ip22/ip22-nvram.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ 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 ] ~

Diff markup

Differences between /arch/mips/sgi-ip22/ip22-nvram.c (Version linux-6.11-rc3) and /arch/mips/sgi-ip22/ip22-nvram.c (Version linux-2.6.0)


  1 // SPDX-License-Identifier: GPL-2.0            << 
  2 /*                                                  1 /*
  3  * ip22-nvram.c: NVRAM and serial EEPROM handl      2  * ip22-nvram.c: NVRAM and serial EEPROM handling.
  4  *                                                  3  *
  5  * Copyright (C) 2003 Ladislav Michl (ladis@li      4  * Copyright (C) 2003 Ladislav Michl (ladis@linux-mips.org)
  6  */                                                 5  */
  7 #include <linux/export.h>                      << 
  8                                                     6 
  9 #include <asm/sgi/hpc3.h>                           7 #include <asm/sgi/hpc3.h>
 10 #include <asm/sgi/ip22.h>                           8 #include <asm/sgi/ip22.h>
 11                                                     9 
 12 /* Control opcode for serial eeprom  */            10 /* Control opcode for serial eeprom  */
 13 #define EEPROM_READ     0xc000  /* serial memo     11 #define EEPROM_READ     0xc000  /* serial memory read */
 14 #define EEPROM_WEN      0x9800  /* write enabl     12 #define EEPROM_WEN      0x9800  /* write enable before prog modes */
 15 #define EEPROM_WRITE    0xa000  /* serial memo     13 #define EEPROM_WRITE    0xa000  /* serial memory write */
 16 #define EEPROM_WRALL    0x8800  /* write all r     14 #define EEPROM_WRALL    0x8800  /* write all registers */
 17 #define EEPROM_WDS      0x8000  /* disable all     15 #define EEPROM_WDS      0x8000  /* disable all programming */
 18 #define EEPROM_PRREAD   0xc000  /* read protec !!  16 #define EEPROM_PRREAD   0xc000  /* read protect register */
 19 #define EEPROM_PREN     0x9800  /* enable prot !!  17 #define EEPROM_PREN     0x9800  /* enable protect register mode */
 20 #define EEPROM_PRCLEAR  0xffff  /* clear prote !!  18 #define EEPROM_PRCLEAR  0xffff  /* clear protect register */
 21 #define EEPROM_PRWRITE  0xa000  /* write prote !!  19 #define EEPROM_PRWRITE  0xa000  /* write protect register */
 22 #define EEPROM_PRDS     0x8000  /* disable pro !!  20 #define EEPROM_PRDS     0x8000  /* disable protect register, forever */
 23                                                    21 
 24 #define EEPROM_EPROT    0x01    /* Protect reg     22 #define EEPROM_EPROT    0x01    /* Protect register enable */
 25 #define EEPROM_CSEL     0x02    /* Chip select     23 #define EEPROM_CSEL     0x02    /* Chip select */
 26 #define EEPROM_ECLK     0x04    /* EEPROM cloc     24 #define EEPROM_ECLK     0x04    /* EEPROM clock */
 27 #define EEPROM_DATO     0x08    /* Data out */     25 #define EEPROM_DATO     0x08    /* Data out */
 28 #define EEPROM_DATI     0x10    /* Data in */      26 #define EEPROM_DATI     0x10    /* Data in */
 29                                                    27 
 30 /* We need to use these functions early... */  !!  28 /* We need to use this functions early... */
 31 #define delay() ({                             !!  29 #define delay() ({                                              \
 32         int x;                                     30         int x;                                                  \
 33         for (x=0; x<100000; x++) __asm__ __vol     31         for (x=0; x<100000; x++) __asm__ __volatile__(""); })
 34                                                    32 
 35 #define eeprom_cs_on(ptr) ({    \                  33 #define eeprom_cs_on(ptr) ({    \
 36         __raw_writel(__raw_readl(ptr) & ~EEPRO !!  34         *ptr &= ~EEPROM_DATO;   \
 37         __raw_writel(__raw_readl(ptr) & ~EEPRO !!  35         *ptr &= ~EEPROM_ECLK;   \
 38         __raw_writel(__raw_readl(ptr) & ~EEPRO !!  36         *ptr &= ~EEPROM_EPROT;  \
 39         delay();                               !!  37         delay();                \
 40         __raw_writel(__raw_readl(ptr) | EEPROM !!  38         *ptr |= EEPROM_CSEL;    \
 41         __raw_writel(__raw_readl(ptr) | EEPROM !!  39         *ptr |= EEPROM_ECLK; })
 42                                                << 
 43                                                    40 
                                                   >>  41                 
 44 #define eeprom_cs_off(ptr) ({   \                  42 #define eeprom_cs_off(ptr) ({   \
 45         __raw_writel(__raw_readl(ptr) & ~EEPRO !!  43         *ptr &= ~EEPROM_ECLK;   \
 46         __raw_writel(__raw_readl(ptr) & ~EEPRO !!  44         *ptr &= ~EEPROM_CSEL;   \
 47         __raw_writel(__raw_readl(ptr) | EEPROM !!  45         *ptr |= EEPROM_EPROT;   \
 48         __raw_writel(__raw_readl(ptr) | EEPROM !!  46         *ptr |= EEPROM_ECLK; })
 49                                                    47 
 50 #define BITS_IN_COMMAND 11                     !!  48 #define BITS_IN_COMMAND 11
 51 /*                                                 49 /*
 52  * clock in the nvram command and the register     50  * clock in the nvram command and the register number. For the
 53  * national semiconductor nv ram chip the op c     51  * national semiconductor nv ram chip the op code is 3 bits and
 54  * the address is 6/8 bits.                    !!  52  * the address is 6/8 bits. 
 55  */                                                53  */
 56 static inline void eeprom_cmd(unsigned int *ct !!  54 static inline void eeprom_cmd(volatile unsigned int *ctrl, unsigned cmd,
                                                   >>  55                               unsigned reg)
 57 {                                                  56 {
 58         unsigned short ser_cmd;                    57         unsigned short ser_cmd;
 59         int i;                                     58         int i;
 60                                                    59 
 61         ser_cmd = cmd | (reg << (16 - BITS_IN_     60         ser_cmd = cmd | (reg << (16 - BITS_IN_COMMAND));
 62         for (i = 0; i < BITS_IN_COMMAND; i++)      61         for (i = 0; i < BITS_IN_COMMAND; i++) {
 63                 if (ser_cmd & (1<<15))  /* if      62                 if (ser_cmd & (1<<15))  /* if high order bit set */
 64                         __raw_writel(__raw_rea !!  63                         *ctrl |= EEPROM_DATO;
 65                 else                               64                 else
 66                         __raw_writel(__raw_rea !!  65                         *ctrl &= ~EEPROM_DATO;
 67                 __raw_writel(__raw_readl(ctrl) !!  66                 *ctrl &= ~EEPROM_ECLK;
 68                 delay();                       !!  67                 *ctrl |= EEPROM_ECLK;
 69                 __raw_writel(__raw_readl(ctrl) << 
 70                 delay();                       << 
 71                 ser_cmd <<= 1;                     68                 ser_cmd <<= 1;
 72         }                                          69         }
 73         /* see data sheet timing diagram */    !!  70         *ctrl &= ~EEPROM_DATO;  /* see data sheet timing diagram */
 74         __raw_writel(__raw_readl(ctrl) & ~EEPR << 
 75 }                                                  71 }
 76                                                    72 
 77 unsigned short ip22_eeprom_read(unsigned int * !!  73 unsigned short ip22_eeprom_read(volatile unsigned int *ctrl, int reg)
 78 {                                                  74 {
 79         unsigned short res = 0;                    75         unsigned short res = 0;
 80         int i;                                     76         int i;
 81                                                    77 
 82         __raw_writel(__raw_readl(ctrl) & ~EEPR !!  78         *ctrl &= ~EEPROM_EPROT;
 83         eeprom_cs_on(ctrl);                        79         eeprom_cs_on(ctrl);
 84         eeprom_cmd(ctrl, EEPROM_READ, reg);        80         eeprom_cmd(ctrl, EEPROM_READ, reg);
 85                                                    81 
 86         /* clock the data ouf of serial mem */     82         /* clock the data ouf of serial mem */
 87         for (i = 0; i < 16; i++) {                 83         for (i = 0; i < 16; i++) {
 88                 __raw_writel(__raw_readl(ctrl) !!  84                 *ctrl &= ~EEPROM_ECLK;
 89                 delay();                           85                 delay();
 90                 __raw_writel(__raw_readl(ctrl) !!  86                 *ctrl |= EEPROM_ECLK;
 91                 delay();                           87                 delay();
 92                 res <<= 1;                         88                 res <<= 1;
 93                 if (__raw_readl(ctrl) & EEPROM !!  89                 if (*ctrl & EEPROM_DATI)
 94                         res |= 1;                  90                         res |= 1;
 95         }                                          91         }
 96                                                !!  92                 
 97         eeprom_cs_off(ctrl);                       93         eeprom_cs_off(ctrl);
 98                                                    94 
 99         return res;                                95         return res;
100 }                                                  96 }
101                                                    97 
102 EXPORT_SYMBOL(ip22_eeprom_read);               << 
103                                                << 
104 /*                                                 98 /*
105  * Read specified register from main NVRAM         99  * Read specified register from main NVRAM
106  */                                               100  */
107 unsigned short ip22_nvram_read(int reg)           101 unsigned short ip22_nvram_read(int reg)
108 {                                                 102 {
109         if (ip22_is_fullhouse())                  103         if (ip22_is_fullhouse())
110                 /* IP22 (Indigo2 aka FullHouse    104                 /* IP22 (Indigo2 aka FullHouse) stores env variables into
111                  * 93CS56 Microwire Bus EEPROM    105                  * 93CS56 Microwire Bus EEPROM 2048 Bit (128x16) */
112                 return ip22_eeprom_read(&hpc3c    106                 return ip22_eeprom_read(&hpc3c0->eeprom, reg);
113         else {                                    107         else {
114                 unsigned short tmp;               108                 unsigned short tmp;
115                 /* IP24 (Indy aka Guiness) use    109                 /* IP24 (Indy aka Guiness) uses DS1386 8K version */
116                 reg <<= 1;                        110                 reg <<= 1;
117                 tmp = hpc3c0->bbram[reg++] & 0    111                 tmp = hpc3c0->bbram[reg++] & 0xff;
118                 return (tmp << 8) | (hpc3c0->b    112                 return (tmp << 8) | (hpc3c0->bbram[reg] & 0xff);
119         }                                      !! 113         }               
120 }                                                 114 }
121                                                << 
122 EXPORT_SYMBOL(ip22_nvram_read);                << 
123                                                   115 

~ [ 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