diff options
| -rw-r--r-- | drivers/mtd/nand/s3c2410.c | 89 |
1 files changed, 78 insertions, 11 deletions
diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c index b7f0740d842f..a2d1c70c5227 100644 --- a/drivers/mtd/nand/s3c2410.c +++ b/drivers/mtd/nand/s3c2410.c | |||
| @@ -74,6 +74,14 @@ static struct nand_ecclayout nand_hw_eccoob = { | |||
| 74 | 74 | ||
| 75 | struct s3c2410_nand_info; | 75 | struct s3c2410_nand_info; |
| 76 | 76 | ||
| 77 | /** | ||
| 78 | * struct s3c2410_nand_mtd - driver MTD structure | ||
| 79 | * @mtd: The MTD instance to pass to the MTD layer. | ||
| 80 | * @chip: The NAND chip information. | ||
| 81 | * @set: The platform information supplied for this set of NAND chips. | ||
| 82 | * @info: Link back to the hardware information. | ||
| 83 | * @scan_res: The result from calling nand_scan_ident(). | ||
| 84 | */ | ||
| 77 | struct s3c2410_nand_mtd { | 85 | struct s3c2410_nand_mtd { |
| 78 | struct mtd_info mtd; | 86 | struct mtd_info mtd; |
| 79 | struct nand_chip chip; | 87 | struct nand_chip chip; |
| @@ -90,6 +98,21 @@ enum s3c_cpu_type { | |||
| 90 | 98 | ||
| 91 | /* overview of the s3c2410 nand state */ | 99 | /* overview of the s3c2410 nand state */ |
| 92 | 100 | ||
| 101 | /** | ||
| 102 | * struct s3c2410_nand_info - NAND controller state. | ||
| 103 | * @mtds: An array of MTD instances on this controoler. | ||
| 104 | * @platform: The platform data for this board. | ||
| 105 | * @device: The platform device we bound to. | ||
| 106 | * @area: The IO area resource that came from request_mem_region(). | ||
| 107 | * @clk: The clock resource for this controller. | ||
| 108 | * @regs: The area mapped for the hardware registers described by @area. | ||
| 109 | * @sel_reg: Pointer to the register controlling the NAND selection. | ||
| 110 | * @sel_bit: The bit in @sel_reg to select the NAND chip. | ||
| 111 | * @mtd_count: The number of MTDs created from this controller. | ||
| 112 | * @save_sel: The contents of @sel_reg to be saved over suspend. | ||
| 113 | * @clk_rate: The clock rate from @clk. | ||
| 114 | * @cpu_type: The exact type of this controller. | ||
| 115 | */ | ||
| 93 | struct s3c2410_nand_info { | 116 | struct s3c2410_nand_info { |
| 94 | /* mtd info */ | 117 | /* mtd info */ |
| 95 | struct nand_hw_control controller; | 118 | struct nand_hw_control controller; |
| @@ -145,6 +168,14 @@ static inline int allow_clk_stop(struct s3c2410_nand_info *info) | |||
| 145 | 168 | ||
| 146 | #define NS_IN_KHZ 1000000 | 169 | #define NS_IN_KHZ 1000000 |
| 147 | 170 | ||
| 171 | /** | ||
| 172 | * s3c_nand_calc_rate - calculate timing data. | ||
| 173 | * @wanted: The cycle time in nanoseconds. | ||
| 174 | * @clk: The clock rate in kHz. | ||
| 175 | * @max: The maximum divider value. | ||
| 176 | * | ||
| 177 | * Calculate the timing value from the given parameters. | ||
| 178 | */ | ||
| 148 | static int s3c_nand_calc_rate(int wanted, unsigned long clk, int max) | 179 | static int s3c_nand_calc_rate(int wanted, unsigned long clk, int max) |
| 149 | { | 180 | { |
| 150 | int result; | 181 | int result; |
| @@ -169,6 +200,14 @@ static int s3c_nand_calc_rate(int wanted, unsigned long clk, int max) | |||
| 169 | 200 | ||
| 170 | /* controller setup */ | 201 | /* controller setup */ |
| 171 | 202 | ||
| 203 | /** | ||
| 204 | * s3c2410_nand_setrate - setup controller timing information. | ||
| 205 | * @info: The controller instance. | ||
| 206 | * | ||
| 207 | * Given the information supplied by the platform, calculate and set | ||
| 208 | * the necessary timing registers in the hardware to generate the | ||
| 209 | * necessary timing cycles to the hardware. | ||
| 210 | */ | ||
| 172 | static int s3c2410_nand_setrate(struct s3c2410_nand_info *info) | 211 | static int s3c2410_nand_setrate(struct s3c2410_nand_info *info) |
| 173 | { | 212 | { |
| 174 | struct s3c2410_platform_nand *plat = info->platform; | 213 | struct s3c2410_platform_nand *plat = info->platform; |
| @@ -245,6 +284,13 @@ static int s3c2410_nand_setrate(struct s3c2410_nand_info *info) | |||
| 245 | return 0; | 284 | return 0; |
| 246 | } | 285 | } |
| 247 | 286 | ||
| 287 | /** | ||
| 288 | * s3c2410_nand_inithw - basic hardware initialisation | ||
| 289 | * @info: The hardware state. | ||
| 290 | * | ||
| 291 | * Do the basic initialisation of the hardware, using s3c2410_nand_setrate() | ||
| 292 | * to setup the hardware access speeds and set the controller to be enabled. | ||
| 293 | */ | ||
| 248 | static int s3c2410_nand_inithw(struct s3c2410_nand_info *info) | 294 | static int s3c2410_nand_inithw(struct s3c2410_nand_info *info) |
| 249 | { | 295 | { |
| 250 | int ret; | 296 | int ret; |
| @@ -268,8 +314,19 @@ static int s3c2410_nand_inithw(struct s3c2410_nand_info *info) | |||
| 268 | return 0; | 314 | return 0; |
| 269 | } | 315 | } |
| 270 | 316 | ||
| 271 | /* select chip */ | 317 | /** |
| 272 | 318 | * s3c2410_nand_select_chip - select the given nand chip | |
| 319 | * @mtd: The MTD instance for this chip. | ||
| 320 | * @chip: The chip number. | ||
| 321 | * | ||
| 322 | * This is called by the MTD layer to either select a given chip for the | ||
| 323 | * @mtd instance, or to indicate that the access has finished and the | ||
| 324 | * chip can be de-selected. | ||
| 325 | * | ||
| 326 | * The routine ensures that the nFCE line is correctly setup, and any | ||
| 327 | * platform specific selection code is called to route nFCE to the specific | ||
| 328 | * chip. | ||
| 329 | */ | ||
| 273 | static void s3c2410_nand_select_chip(struct mtd_info *mtd, int chip) | 330 | static void s3c2410_nand_select_chip(struct mtd_info *mtd, int chip) |
| 274 | { | 331 | { |
| 275 | struct s3c2410_nand_info *info; | 332 | struct s3c2410_nand_info *info; |
| @@ -667,11 +724,16 @@ static int s3c2410_nand_add_partition(struct s3c2410_nand_info *info, | |||
| 667 | } | 724 | } |
| 668 | #endif | 725 | #endif |
| 669 | 726 | ||
| 670 | /* s3c2410_nand_init_chip | 727 | /** |
| 728 | * s3c2410_nand_init_chip - initialise a single instance of an chip | ||
| 729 | * @info: The base NAND controller the chip is on. | ||
| 730 | * @nmtd: The new controller MTD instance to fill in. | ||
| 731 | * @set: The information passed from the board specific platform data. | ||
| 671 | * | 732 | * |
| 672 | * init a single instance of an chip | 733 | * Initialise the given @nmtd from the information in @info and @set. This |
| 673 | */ | 734 | * readies the structure for use with the MTD layer functions by ensuring |
| 674 | 735 | * all pointers are setup and the necessary control routines selected. | |
| 736 | */ | ||
| 675 | static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info, | 737 | static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info, |
| 676 | struct s3c2410_nand_mtd *nmtd, | 738 | struct s3c2410_nand_mtd *nmtd, |
| 677 | struct s3c2410_nand_set *set) | 739 | struct s3c2410_nand_set *set) |
| @@ -759,12 +821,17 @@ static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info, | |||
| 759 | chip->ecc.mode = NAND_ECC_NONE; | 821 | chip->ecc.mode = NAND_ECC_NONE; |
| 760 | } | 822 | } |
| 761 | 823 | ||
| 762 | /* s3c2410_nand_update_chip | 824 | /** |
| 825 | * s3c2410_nand_update_chip - post probe update | ||
| 826 | * @info: The controller instance. | ||
| 827 | * @nmtd: The driver version of the MTD instance. | ||
| 763 | * | 828 | * |
| 764 | * post-probe chip update, to change any items, such as the | 829 | * This routine is called after the chip probe has succesfully completed |
| 765 | * layout for large page nand | 830 | * and the relevant per-chip information updated. This call ensure that |
| 766 | */ | 831 | * we update the internal state accordingly. |
| 767 | 832 | * | |
| 833 | * The internal state is currently limited to the ECC state information. | ||
| 834 | */ | ||
| 768 | static void s3c2410_nand_update_chip(struct s3c2410_nand_info *info, | 835 | static void s3c2410_nand_update_chip(struct s3c2410_nand_info *info, |
| 769 | struct s3c2410_nand_mtd *nmtd) | 836 | struct s3c2410_nand_mtd *nmtd) |
| 770 | { | 837 | { |
