2019-05-23 16:14:39 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2005-11-07 18:15:31 +07:00
|
|
|
/*
|
2010-08-09 02:58:20 +07:00
|
|
|
* Copyright © 2000 Red Hat UK Limited
|
|
|
|
* Copyright © 2000-2010 David Woodhouse <dwmw2@infradead.org>
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __MTD_FLASHCHIP_H__
|
|
|
|
#define __MTD_FLASHCHIP_H__
|
|
|
|
|
|
|
|
/* For spinlocks. sched.h includes spinlock.h from whichever directory it
|
|
|
|
* happens to be in - so we don't have to care whether we're on 2.2, which
|
2005-11-07 18:15:31 +07:00
|
|
|
* has asm/spinlock.h, or 2.4, which has linux/spinlock.h
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
|
|
|
#include <linux/sched.h>
|
2010-04-19 03:46:44 +07:00
|
|
|
#include <linux/mutex.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-11-07 18:15:31 +07:00
|
|
|
typedef enum {
|
2005-04-17 05:20:36 +07:00
|
|
|
FL_READY,
|
|
|
|
FL_STATUS,
|
|
|
|
FL_CFI_QUERY,
|
|
|
|
FL_JEDEC_QUERY,
|
|
|
|
FL_ERASING,
|
|
|
|
FL_ERASE_SUSPENDING,
|
|
|
|
FL_ERASE_SUSPENDED,
|
|
|
|
FL_WRITING,
|
|
|
|
FL_WRITING_TO_BUFFER,
|
2005-02-09 00:11:19 +07:00
|
|
|
FL_OTP_WRITE,
|
2005-04-17 05:20:36 +07:00
|
|
|
FL_WRITE_SUSPENDING,
|
|
|
|
FL_WRITE_SUSPENDED,
|
|
|
|
FL_PM_SUSPENDED,
|
|
|
|
FL_SYNCING,
|
|
|
|
FL_UNLOADING,
|
|
|
|
FL_LOCKING,
|
|
|
|
FL_UNLOCKING,
|
|
|
|
FL_POINT,
|
|
|
|
FL_XIP_WHILE_ERASING,
|
|
|
|
FL_XIP_WHILE_WRITING,
|
2007-10-03 03:56:04 +07:00
|
|
|
FL_SHUTDOWN,
|
2009-09-21 04:28:14 +07:00
|
|
|
/* These 2 come from nand_state_t, which has been unified here */
|
|
|
|
FL_READING,
|
|
|
|
FL_CACHEDPRG,
|
2009-10-23 12:50:43 +07:00
|
|
|
/* These 4 come from onenand_state_t, which has been unified here */
|
2009-09-21 04:28:14 +07:00
|
|
|
FL_RESETING,
|
|
|
|
FL_OTPING,
|
2009-10-23 12:50:43 +07:00
|
|
|
FL_PREPARING_ERASE,
|
|
|
|
FL_VERIFYING_ERASE,
|
2009-09-21 04:28:14 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
FL_UNKNOWN
|
|
|
|
} flstate_t;
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-11-07 18:15:31 +07:00
|
|
|
/* NOTE: confusingly, this can be used to refer to more than one chip at a time,
|
2005-04-17 05:20:36 +07:00
|
|
|
if they're interleaved. This can even refer to individual partitions on
|
|
|
|
the same physical chip when present. */
|
|
|
|
|
|
|
|
struct flchip {
|
|
|
|
unsigned long start; /* Offset within the map */
|
|
|
|
// unsigned long len;
|
|
|
|
/* We omit len for now, because when we group them together
|
|
|
|
we insist that they're all of the same size, and the chip size
|
|
|
|
is held in the next level up. If we get more versatile later,
|
|
|
|
it'll make it a damn sight harder to find which chip we want from
|
|
|
|
a given offset, and we'll want to add the per-chip length field
|
|
|
|
back in.
|
|
|
|
*/
|
|
|
|
int ref_point_counter;
|
|
|
|
flstate_t state;
|
|
|
|
flstate_t oldstate;
|
|
|
|
|
2005-03-15 01:27:18 +07:00
|
|
|
unsigned int write_suspended:1;
|
|
|
|
unsigned int erase_suspended:1;
|
2005-04-17 05:20:36 +07:00
|
|
|
unsigned long in_progress_block_addr;
|
2018-03-01 20:39:39 +07:00
|
|
|
unsigned long in_progress_block_mask;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2010-04-19 03:46:44 +07:00
|
|
|
struct mutex mutex;
|
2005-04-17 05:20:36 +07:00
|
|
|
wait_queue_head_t wq; /* Wait on here when we're waiting for the chip
|
|
|
|
to be ready */
|
|
|
|
int word_write_time;
|
|
|
|
int buffer_write_time;
|
|
|
|
int erase_time;
|
|
|
|
|
2008-08-05 23:37:41 +07:00
|
|
|
int word_write_time_max;
|
|
|
|
int buffer_write_time_max;
|
|
|
|
int erase_time_max;
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
void *priv;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* This is used to handle contention on write/erase operations
|
|
|
|
between partitions of the same physical chip. */
|
|
|
|
struct flchip_shared {
|
2010-08-05 14:19:26 +07:00
|
|
|
struct mutex lock;
|
2005-04-17 05:20:36 +07:00
|
|
|
struct flchip *writing;
|
|
|
|
struct flchip *erasing;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* __MTD_FLASHCHIP_H__ */
|