+++ /dev/null
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- * either express or implied. See the License for the specific
- * language governing permissions and limitations under the License.
- *
- ****************************************************************************/
-/****************************************************************************
- * arch/arm/src/s5j/s5j_nvram.c
- *
- * Copyright (C) 2009-2010, 2014-2015 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <gnutt@nuttx.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name NuttX nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- ****************************************************************************/
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-#include <tinyara/config.h>
-#include <tinyara/arch.h>
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-
-#include <tinyara/kmalloc.h>
-
-#include <arch/chip/irq.h>
-#include <tinyara/watchdog.h>
-#include <arch/chip/chip_types.h>
-
-#include "chip.h"
-#include "up_arch.h"
-#include "cache.h"
-#include "mpu.h"
-
-#include <tinyara/clock.h>
-#include <clock/clock.h>
-#include <pthread.h>
-#include <semaphore.h>
-#include <up_internal.h>
-
-/****************************************************************************
- * Private Functions Prototypes
- ****************************************************************************/
-
-/****************************************************************************
- * Private Types
- ****************************************************************************/
-
-/****************************************************************************
- * Static Function Prototypes
- ****************************************************************************/
-
-/****************************************************************************
- * Private Data
- ****************************************************************************/
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-/****************************************************************************
- * Private Types
- ****************************************************************************/
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-unsigned int Nv_Write(unsigned int target_addr, unsigned int source_addr, unsigned int sizebyte)
-{
- int ret;
-
- ret = false;
- if ((target_addr < CONFIG_NVRAM_WIFI_START)
- || ((target_addr + sizebyte) > (CONFIG_NVRAM_WIFI_START + 8 * 1024))
- || (sizebyte > (8 * 1024))) {
- lldbg("Unable to access\n");
- return false;
- }
-
- s5j_qspi_disable_wp();
-
- //Page Programming
- SetBits(rSF_CON, 15, 0x1, 1);
-
- // Checks Address range (16MB)
- if (((target_addr - CONFIG_S5J_FLASH_BASE) >> 24) > 0) { // 16MB
- lldbg("Flash Address range over!(24bit range)\n");
- goto err;
- }
-
- memcpy((void *)target_addr, (void *)source_addr, sizebyte);
- arch_flush_dcache(CONFIG_NVRAM_WIFI_START, CONFIG_NVRAM_WIFI_START + 8 * 1024);
-
- ret = true;
-err:
- s5j_qspi_enable_wp();
- return ret;
-}
-
-unsigned int Nv_Read(unsigned int target_addr, unsigned int source_addr, unsigned int sizebyte)
-{
- if ((source_addr < CONFIG_NVRAM_WIFI_START)
- || ((source_addr + sizebyte) > (CONFIG_NVRAM_WIFI_START + 8 * 1024))
- || (sizebyte > (8 * 1024))) {
- lldbg("Unable to access\n");
- return false;
- }
-
- memcpy((void *)target_addr, (void *)source_addr, sizebyte);
- return true;
-}
-
-unsigned int Nv_Erase(unsigned int target_addr, unsigned int sizebyte)
-{
- if ((target_addr < CONFIG_NVRAM_WIFI_START)
- || ((target_addr + sizebyte) > (CONFIG_NVRAM_WIFI_START + 8 * 1024))
- || (sizebyte > (8 * 1024))) {
- lldbg("Unable to access\n");
- return false;
- }
- //Disable WP(Write Protect)
- SetBits(rSF_CON, 31, 0x1U, 1U);
-
- //Page Programming
- SetBits(rSF_CON, 15, 0x1, 1);
-
- // Checks Address range (16MB)
- if (((target_addr - CONFIG_S5J_FLASH_BASE) >> 24) > 0) { // 16MB
- lldbg("Flash Address range over!(24bit range)\n");
- return false;
- }
- //Checks sector(4KB) align
- if ((target_addr & 0xFFF) != 0) {
- lldbg("4KB alignment failure\n");
- return false;
- }
-
- arch_flush_dcache(CONFIG_NVRAM_WIFI_START, CONFIG_NVRAM_WIFI_START + 8 * 1024);
-
- //should be erased before writing.
- if (s5j_qspi_erase(target_addr, sizebyte) == false) {
- lldbg("Erase Failure\n");
- return false;
- }
-
- return true;
-}
-
-unsigned int s5j_nvram_write(unsigned int target_addr, unsigned int source_addr, unsigned int sizebyte)
-{
- return Nv_Write(target_addr, source_addr, sizebyte);
-}
-
-unsigned int s5j_nvram_read(unsigned int target_addr, unsigned int source_addr, unsigned int sizebyte)
-{
- return Nv_Read(target_addr, source_addr, sizebyte);
-}
-
-unsigned int s5j_nvram_erase(unsigned int target_addr, unsigned int sizebyte)
-{
- return Nv_Erase(target_addr, sizebyte);
-}
/****************************************************************************
*
- * Copyright 2016 Samsung Electronics All Rights Reserved.
+ * Copyright 2017 Samsung Electronics Co., LTD. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
****************************************************************************/
/****************************************************************************
- * arch/arm/src/s5j/s5j_nvram.h
+ * arch/arm/src/sidk_s5jt200/sidk200_nvram.c
*
- * Copyright (C) 2009, 2014 Gregory Nutt. All rights reserved.
- * Author:
+ * Copyright (C) 2015 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
- * 3. Neither the name NuttX nor the names of its contributors may be
+ * 3. Neither the name tinyara nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
-#ifndef __ARCH_ARM_SRC_S5J_S5J_NVRAM_H
-#define __ARCH_ARM_SRC_S5J_S5J_NVRAM_H
-/****************************************************************************
- * Included Files
- ****************************************************************************/
+#include <tinyara/config.h>
+
+#include <fcntl.h>
+#include <stdbool.h>
+#include <debug.h>
+
+#include <tinyara/configdata.h>
+
+#include "sidk_s5jt200.h"
+
/****************************************************************************
* Public Functions
****************************************************************************/
-unsigned int Nv_Write(unsigned int target_addr, unsigned int source_addr, unsigned int sizebyte);
-unsigned int Nv_Read(unsigned int target_addr, unsigned int source_addr, unsigned int sizebyte);
-unsigned int Nv_Erase(unsigned int target_addr, unsigned int sizebyte);
-unsigned int s5j_nvram_write(unsigned int target_addr, unsigned int source_addr, unsigned int sizebyte);
-unsigned int s5j_nvram_read(unsigned int target_addr, unsigned int source_addr, unsigned int sizebyte);
-unsigned int s5j_nvram_erase(unsigned int target_addr, unsigned int sizebyte);
-#endif /* __ARCH_ARM_SRC_S5J_S5J_NVRAM_H */
+unsigned int Nv_Write(unsigned int target_addr, unsigned int source_addr,
+ unsigned int sizebyte)
+{
+#if defined(CONFIG_MTD_CONFIG)
+ int fd;
+ struct config_data_s config;
+
+ fd = open("/dev/config", O_RDOK);
+ if (fd < 0) {
+ lldbg("Failed to open /dev/config\n");
+ return false;
+ }
+
+ config.id = SIDK_S5JT200_CONFIGDATA_WIFI_NVRAM;
+ config.instance = 0;
+ config.configdata = (unsigned char *)source_addr;
+ config.len = sizebyte;
+
+ ioctl(fd, CFGDIOC_SETCONFIG, &config);
+ close(fd);
+
+ return true;
+#else
+ return false;
+#endif
+}
+
+unsigned int Nv_Read(unsigned int target_addr, unsigned int source_addr,
+ unsigned int sizebyte)
+{
+#if defined(CONFIG_MTD_CONFIG)
+ int fd;
+ struct config_data_s config;
+
+ fd = open("/dev/config", O_RDOK);
+ if (fd < 0) {
+ lldbg("Failed to open /dev/config\n");
+ return false;
+ }
+
+ config.id = SIDK_S5JT200_CONFIGDATA_WIFI_NVRAM;
+ config.instance = 0;
+ config.configdata = (unsigned char *)target_addr;
+ config.len = sizebyte;
+
+ ioctl(fd, CFGDIOC_GETCONFIG, &config);
+ close(fd);
+
+ return true;
+#else
+ return false;
+#endif
+}
+
+unsigned int Nv_Erase(unsigned int target_addr, unsigned int sizebyte)
+{
+#if defined(CONFIG_MTD_CONFIG)
+ return true;
+#else
+ return false;
+#endif
+}