summaryrefslogtreecommitdiff
path: root/src/flash/nand.c
diff options
context:
space:
mode:
authordrath <drath@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-02-19 19:52:09 +0000
committerdrath <drath@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-02-19 19:52:09 +0000
commitee340df8417772b8c29a54ddf7b36556ec20d609 (patch)
treeabd649dfc9a456182e428f62a34f392f02b0fdd9 /src/flash/nand.c
parent5c0e8efa051f4e266add8b3685020970fe394a4c (diff)
downloadopenocd+libswd-ee340df8417772b8c29a54ddf7b36556ec20d609.tar.gz
openocd+libswd-ee340df8417772b8c29a54ddf7b36556ec20d609.tar.bz2
openocd+libswd-ee340df8417772b8c29a54ddf7b36556ec20d609.tar.xz
openocd+libswd-ee340df8417772b8c29a54ddf7b36556ec20d609.zip
- add support for the majority of the Samsung ARM SoC family, S3C2410, S3C2412, S3C2413, S3C2440 and S3C2443 (thanks to Ben Dooks for this patch)
git-svn-id: svn://svn.berlios.de/openocd/trunk@311 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/flash/nand.c')
-rw-r--r--src/flash/nand.c127
1 files changed, 77 insertions, 50 deletions
diff --git a/src/flash/nand.c b/src/flash/nand.c
index 52c92328..3c00db1d 100644
--- a/src/flash/nand.c
+++ b/src/flash/nand.c
@@ -63,13 +63,20 @@ int nand_write_page(struct nand_device_s *device, u32 page, u8 *data, u32 data_s
/* NAND flash controller
*/
extern nand_flash_controller_t lpc3180_nand_controller;
-/* extern nand_flash_controller_t s3c2410_nand_controller; */
+extern nand_flash_controller_t s3c2410_nand_controller;
+extern nand_flash_controller_t s3c2412_nand_controller;
+extern nand_flash_controller_t s3c2440_nand_controller;
+extern nand_flash_controller_t s3c2443_nand_controller;
+
/* extern nand_flash_controller_t boundary_scan_nand_controller; */
nand_flash_controller_t *nand_flash_controllers[] =
{
&lpc3180_nand_controller,
-/* &s3c2410_nand_controller, */
+ &s3c2410_nand_controller,
+ &s3c2412_nand_controller,
+ &s3c2440_nand_controller,
+ &s3c2443_nand_controller,
/* &boundary_scan_nand_controller, */
NULL
};
@@ -707,7 +714,7 @@ int nand_write_page(struct nand_device_s *device, u32 page, u8 *data, u32 data_s
if (!device->device)
return ERROR_NAND_DEVICE_NOT_PROBED;
- if (device->use_raw)
+ if (device->use_raw || device->controller->write_page == NULL)
return nand_write_page_raw(device, page, data, data_size, oob, oob_size);
else
return device->controller->write_page(device, page, data, data_size, oob, oob_size);
@@ -718,7 +725,7 @@ int nand_read_page(struct nand_device_s *device, u32 page, u8 *data, u32 data_si
if (!device->device)
return ERROR_NAND_DEVICE_NOT_PROBED;
- if (device->use_raw)
+ if (device->use_raw || device->controller->read_page == NULL)
return nand_read_page_raw(device, page, data, data_size, oob, oob_size);
else
return device->controller->read_page(device, page, data, data_size, oob, oob_size);
@@ -782,38 +789,48 @@ int nand_read_page_raw(struct nand_device_s *device, u32 page, u8 *data, u32 dat
if (data)
{
- for (i = 0; i < data_size;)
+ if (device->controller->read_block_data != NULL)
+ (device->controller->read_block_data)(device, data, data_size);
+ else
{
- if (device->device->options & NAND_BUSWIDTH_16)
- {
- device->controller->read_data(device, data);
- data += 2;
- i += 2;
- }
- else
+ for (i = 0; i < data_size;)
{
- device->controller->read_data(device, data);
- data += 1;
- i += 1;
+ if (device->device->options & NAND_BUSWIDTH_16)
+ {
+ device->controller->read_data(device, data);
+ data += 2;
+ i += 2;
+ }
+ else
+ {
+ device->controller->read_data(device, data);
+ data += 1;
+ i += 1;
+ }
}
}
}
if (oob)
{
- for (i = 0; i < oob_size;)
+ if (device->controller->read_block_data != NULL)
+ (device->controller->read_block_data)(device, oob, oob_size);
+ else
{
- if (device->device->options & NAND_BUSWIDTH_16)
+ for (i = 0; i < oob_size;)
{
- device->controller->read_data(device, oob);
- oob += 2;
- i += 2;
- }
- else
- {
- device->controller->read_data(device, oob);
- oob += 1;
- i += 1;
+ if (device->device->options & NAND_BUSWIDTH_16)
+ {
+ device->controller->read_data(device, oob);
+ oob += 2;
+ i += 2;
+ }
+ else
+ {
+ device->controller->read_data(device, oob);
+ oob += 1;
+ i += 1;
+ }
}
}
}
@@ -868,40 +885,50 @@ int nand_write_page_raw(struct nand_device_s *device, u32 page, u8 *data, u32 da
if (data)
{
- for (i = 0; i < data_size;)
+ if (device->controller->write_block_data != NULL)
+ (device->controller->write_block_data)(device, data, data_size);
+ else
{
- if (device->device->options & NAND_BUSWIDTH_16)
+ for (i = 0; i < data_size;)
{
- u16 data_buf = le_to_h_u16(data);
- device->controller->write_data(device, data_buf);
- data += 2;
- i += 2;
- }
- else
- {
- device->controller->write_data(device, *data);
- data += 1;
- i += 1;
+ if (device->device->options & NAND_BUSWIDTH_16)
+ {
+ u16 data_buf = le_to_h_u16(data);
+ device->controller->write_data(device, data_buf);
+ data += 2;
+ i += 2;
+ }
+ else
+ {
+ device->controller->write_data(device, *data);
+ data += 1;
+ i += 1;
+ }
}
}
}
if (oob)
{
- for (i = 0; i < oob_size;)
+ if (device->controller->write_block_data != NULL)
+ (device->controller->write_block_data)(device, oob, oob_size);
+ else
{
- if (device->device->options & NAND_BUSWIDTH_16)
+ for (i = 0; i < oob_size;)
{
- u16 oob_buf = le_to_h_u16(data);
- device->controller->write_data(device, oob_buf);
- oob += 2;
- i += 2;
- }
- else
- {
- device->controller->write_data(device, *oob);
- oob += 1;
- i += 1;
+ if (device->device->options & NAND_BUSWIDTH_16)
+ {
+ u16 oob_buf = le_to_h_u16(data);
+ device->controller->write_data(device, oob_buf);
+ oob += 2;
+ i += 2;
+ }
+ else
+ {
+ device->controller->write_data(device, *oob);
+ oob += 1;
+ i += 1;
+ }
}
}
}