/* * include/asm/arch/nvram.h * * Copyright (C) 2009 SPiDCOM Technologies * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #ifndef __ASM_ARCH_NVRAM_H #define __ASM_ARCH_NVRAM_H #define NVRAM_MTD_NAME "nvram" #define SPC300_NVRAM_MAGIC "NVRAM\0\0\0" #define NVRAM_IS_VALID(nvram) (!memcmp(nvram->magic, SPC300_NVRAM_MAGIC, 8)) /* GPIO common definitions */ #define MAX_INTERNAL_GPIOS 16 #define MIN_INTERNAL_GPIOS 8 #define spc300_gpio_max_nb(pkg_cfg) ((((pkg_cfg & 0x000000F0) >> 4) < 5) ? \ MAX_INTERNAL_GPIOS : MIN_INTERNAL_GPIOS) #define spc300_gpio_direction(gpio_allow_dir,num) ((gpio_allow_dir >> (num * 2)) & 0x3) enum spc300_gpio_direction_t { SPC300_GPIO_DIRECTION_NONE = 0, SPC300_GPIO_DIRECTION_INPUT = 1, SPC300_GPIO_DIRECTION_OUTPUT = 2, SPC300_GPIO_DIRECTION_BIDIR = 3, }; /* /!\ All values are LITTLE-ENDIAN */ typedef struct { char magic[8]; // Magic number "NVRAM\0\0\0" uint32_t pkg_cfg; // SPC300 package configuration register uint32_t gpio_0_7_cfg; // SPC300 GPIO 0 to 7 configuration register uint32_t gpio_8_15_cfg; // SPC300 GPIO 8 to 15 configuration register uint32_t gpio_allow_dir; // SPC300 GPIO allowed directions 0:none 1:in 2:out 3:bi uint32_t sdram_config; // SPC300 SDRAM configuration register uint32_t sdram_timing0; // SPC300 SDRAM timing register 0 uint32_t sdram_timing1; // SPC300 SDRAM timing register 1 uint32_t sdram_refresh; // SPC300 SDRAM refresh register uint32_t flash_org; // Flash organization uint32_t img_0_offset; // Offset of first image address uint32_t nb_images; // Max Number of Images present in flash char product_name[64]; // Product short name in string format char product_partnb[64]; // Product part number in string format char product_desc[128]; // Product long description in string format char serial_number[64]; // Product serial number in string format uint32_t eth_phy_addr; // Address of Ethernet PHY unsigned char eth_address[6]; // Ethernet MAC address unsigned char eth_port_nb; // Ethernet port number unsigned char reserved1; unsigned char plc_address[6]; // PowerLine MAC address unsigned char reserved2[2]; char device_password[32]; // HomePlugAV device unique password (DPW) char oem_info[64]; // Additional information for OEM unsigned char tonemask[192]; // HomePlugAV tonemask char manufactory_info[64]; // Name of the product manufacturer uint32_t img_max_size; // Max size of an image in // flash uint32_t cpu_partnb; // SPC3x0 partnb } spc300_nvram_t; //Currently __attribute__((packed)) not needed #ifdef __KERNEL__ extern spc300_nvram_t spc300_nvram; static inline void spc300_nvram_copy(void* dst, void* src, unsigned int length) { unsigned int burst, rest, i; unsigned long *src32, *dst32; unsigned char *src8, *dst8; src32 = (unsigned long*)src; dst32 = (unsigned long*)dst; burst = length / 4; rest = length % 4; for(i=0 ; i