1#- 2# Copyright (C) 2009-2012 Semihalf 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions 7# are met: 8# 1. Redistributions of source code must retain the above copyright 9# notice, this list of conditions and the following disclaimer. 10# 2. Redistributions in binary form must reproduce the above copyright 11# notice, this list of conditions and the following disclaimer in the 12# documentation and/or other materials provided with the distribution. 13# 14# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24# SUCH DAMAGE. 25# 26# $FreeBSD$ 27 28# NAND controller interface description 29# 30 31#include <sys/bus.h> 32#include <dev/nand/nand.h> 33 34INTERFACE nfc; 35 36CODE { 37 static int nfc_default_method(device_t dev) 38 { 39 return (0); 40 } 41 42 static int nfc_softecc_get(device_t dev, void *buf, int pagesize, 43 void *ecc, int *needwrite) 44 { 45 *needwrite = 1; 46 return (nand_softecc_get(dev, buf, pagesize, ecc)); 47 } 48 49 static int nfc_softecc_correct(device_t dev, void *buf, int pagesize, 50 void *readecc, void *calcecc) 51 { 52 return (nand_softecc_correct(dev, buf, pagesize, readecc, 53 calcecc)); 54 } 55}; 56 57# Send command to a NAND chip 58# 59# Return values: 60# 0: Success 61# 62METHOD int send_command { 63 device_t dev; 64 uint8_t command; 65}; 66 67# Send address to a NAND chip 68# 69# Return values: 70# 0: Success 71# 72METHOD int send_address { 73 device_t dev; 74 uint8_t address; 75}; 76 77# Read byte 78# 79# Return values: 80# byte read 81# 82METHOD uint8_t read_byte { 83 device_t dev; 84}; 85 86# Write byte 87# 88METHOD void write_byte { 89 device_t dev; 90 uint8_t byte; 91}; 92 93# Read word 94# 95# Return values: 96# word read 97# 98METHOD uint16_t read_word { 99 device_t dev; 100}; 101 102# Write word 103# 104METHOD void write_word { 105 device_t dev; 106 uint16_t word; 107}; 108 109# Read buf 110# 111METHOD void read_buf { 112 device_t dev; 113 void *buf; 114 uint32_t len; 115}; 116 117# Write buf 118# 119METHOD void write_buf { 120 device_t dev; 121 void *buf; 122 uint32_t len; 123}; 124 125# Select CS 126# 127METHOD int select_cs { 128 device_t dev; 129 uint8_t cs; 130}; 131 132# Read ready/busy signal 133# 134METHOD int read_rnb { 135 device_t dev; 136}; 137 138# Start command 139# 140# Return values: 141# 0: Success 142# 143METHOD int start_command { 144 device_t dev; 145} DEFAULT nfc_default_method; 146 147# Generate ECC or get it from H/W 148# 149METHOD int get_ecc { 150 device_t dev; 151 void *buf; 152 int pagesize; 153 void *ecc; 154 int *needwrite; 155} DEFAULT nfc_softecc_get; 156 157# Correct ECC 158# 159METHOD int correct_ecc { 160 device_t dev; 161 void *buf; 162 int pagesize; 163 void *readecc; 164 void *calcecc; 165} DEFAULT nfc_softecc_correct; 166