+ /* we have to be carefull not to overflow the buffer if len is
+ * not a multiple of 4 */
+ unsigned long num_words = len & 0xfffffffc;
+ unsigned long rest = len & 0x3;
+
+ /* if there are any, first copy multiple of 4 bytes */
+ if(num_words) {
+ for(i=0; i<num_words; i+=4)
+ buf[i] = NDDB;
+ }
+
+ /* ...then the rest */
+ if(rest) {
+ unsigned long rest_data = NDDB;
+ for(j=0;j<rest;j++)
+ buf[i+j] = (u_char) ((rest_data>>j) & 0xff);
+ }
+
+ return;
+}
+
+/* global var, too bad */
+static unsigned long read_buf = 0;
+static unsigned char bytes_read = 0;
+
+static u_char delta_read_byte(struct mtd_info *mtd)
+{
+/* struct nand_chip *this = mtd->priv; */
+ unsigned char byte;
+
+ if(bytes_read == 0) {
+ /* wait for read request */
+ while(1) {
+ if(NDSR & NDSR_RDDREQ) {
+ NDSR |= NDSR_RDDREQ;
+ break;
+ }
+ }
+ read_buf = NDDB;
+ printk("delta_read_byte: 0x%x.\n", read_buf);
+ }
+ byte = (unsigned char) (read_buf>>(8 * bytes_read++));
+ if(bytes_read >= 4)
+ bytes_read = 0;
+
+ printf("delta_read_byte: returning 0x%x.\n", byte);
+ return byte;