On Mon, Aug 29, 2011 at 4:13 PM, Mike Frysinger <[email protected]> wrote:
> On Monday, August 29, 2011 15:54:35 Jie Zhang wrote:
>> On Mon, Aug 29, 2011 at 3:22 PM, Mike Frysinger <[email protected]> wrote:
>> > On Monday, August 29, 2011 10:38:17 Jie Zhang wrote:
>> >> I have committed this patch to add BF527 SDP board bus support. I did
>> >> the test by detectflash, but did not try flashmem.
>> >
>> > this already works with the bf52x bus.  simply pass HWAIT=PG0 when
>> > initializing it.  i tested that with detecting, reading, and writing
>> > flash when i implemented it.
>>
>> I was wondering what's the use of HWAIT. Now I see. Thank you!
>>
>> But the problem is it's not easy for user to know they can use this
>> parameter for BF527 SDP board. As I said before, we should allow user
>> to add board names to initbus explicitly. Otherwise, people will keep
>> asking if board FOO is supported or not.
>
> the trouble is that PG0 isnt specific to the BF527 SDP board.  if you read the
> HRM, PG0 is the default HWAIT signal for all BF52x procs.  and iirc, you can
> change this in the OTP.  i dont have a BF52x HRM handy atm to refresh my
> memory on the specifics.
>
I don't know what HWAIT stands for. I cannot think it's related to
flash enable signal from the name. If you have named it as
sig_flash_enable and sig_flash_enable_level, I might have read the
related code carefully. I thought it was some kind of hack from the
first look. I think it will be better to make a patch to rename it to
something more meaningful.

> i dont mind adding an alias for it, but it shouldnt be a dedicated board like
> this.
>
>> Is there a way to put bf527_sdp into bf537_stamp.c like setting a
>> default value to hwait and hwait_level?
>
> we might have to restructure a little to make it simpler ...
>
After some thinking, I come up with this patch. The code can be
extended for several more boards like bf527_sdp, but will not look
pretty for more than that. What do you think?


Regards,
Jie
  * src/bus/bf537_stamp.c (bf537_stamp_bus_new): Support bf527_sdp.
    (bf527_sdp): _BFIN_BUS_DECLARE.
  * src/bus/blackfin.h (BFIN_BUS_PARAM_HWAIT): Define.
  * src/bus/Makefile.am (libbus_la_SOURCES): Remove bf527_sdp.c.
  * src/bus/bf527_sdp.c: Remove.

Index: urjtag/src/bus/bf537_stamp.c
===================================================================
--- urjtag/src/bus/bf537_stamp.c	(revision 1992)
+++ urjtag/src/bus/bf537_stamp.c	(working copy)
@@ -34,12 +34,14 @@ bf537_stamp_bus_new (urj_chain_t *chain,
                      const urj_param_t *cmd_params[])
 {
     urj_bus_t *bus;
+    urj_part_t *part;
     bfin_bus_params_t *params;
     int failed = 0;
 
     bus = urj_bus_generic_new (chain, driver, sizeof (bus_params_t));
     if (bus == NULL)
         return NULL;
+    part = bus->part;
 
     params = bus->params;
     params->async_size = 4 * 1024 * 1024;
@@ -50,6 +52,14 @@ bf537_stamp_bus_new (urj_chain_t *chain,
     params->sdram = 1;
     failed |= bfin_bus_new (bus, cmd_params);
 
+    /* If it's a BF527 SDP board, PG0 is used as ~FLASH_EN.  */
+    if (strcmp (driver->name, "bf527_sdp") == 0)
+    {
+        failed |= urj_bus_generic_attach_sig (part, &BFIN_BUS_PARAM_HWAIT,
+                                              "PG0");
+        params->hwait_level = 0;
+    }
+
     if (failed)
     {
         urj_bus_generic_free (bus);
@@ -62,6 +72,7 @@ bf537_stamp_bus_new (urj_chain_t *chain,
 BFIN_BUS_DECLARE(bf537_stamp, "BF537 Stamp board");
 _BFIN_BUS_DECLARE(bf537_ezkit, bf537_stamp, "BF537 EZ-Kit board");
 _BFIN_BUS_DECLARE(bf527_ezkit, bf537_stamp, "BF527 EZ-Kit board");
+_BFIN_BUS_DECLARE(bf527_sdp, bf537_stamp, "BF527 SDP board");
 _BFIN_BUS_DECLARE(bf538f_ezkit, bf537_stamp, "BF538F EZ-Kit board");
 _BFIN_BUS_DECLARE(bf526_ezkit, bf537_stamp, "BF526 EZ-Kit board");
 _BFIN_BUS_DECLARE(bf533_ezkit, bf537_stamp, "BF533 EZ-Kit board");
Index: urjtag/src/bus/blackfin.h
===================================================================
--- urjtag/src/bus/blackfin.h	(revision 1992)
+++ urjtag/src/bus/blackfin.h	(working copy)
@@ -41,6 +41,8 @@ typedef struct {
     void (*unselect_flash) (urj_bus_t *bus);
 } bfin_bus_params_t;
 
+#define BFIN_BUS_PARAM_HWAIT  ((bfin_bus_params_t *) bus->params)->hwait
+
 int bfin_bus_new (urj_bus_t *bus, const urj_param_t *cmd_params[]);
 
 int bfin_bus_area (urj_bus_t *bus, uint32_t adr, urj_bus_area_t *area);
Index: urjtag/src/bus/Makefile.am
===================================================================
--- urjtag/src/bus/Makefile.am	(revision 1992)
+++ urjtag/src/bus/Makefile.am	(working copy)
@@ -56,7 +56,6 @@ libbus_la_SOURCES += \
 	blackfin.c \
 	blackfin.h \
 	bf518f_ezbrd.c \
-	bf527_sdp.c \
 	bf533_stamp.c \
 	bf537_stamp.c \
 	bf548_ezkit.c \
Index: urjtag/src/bus/bf527_sdp.c
===================================================================
--- urjtag/src/bus/bf527_sdp.c	(revision 1975)
+++ urjtag/src/bus/bf527_sdp.c	(working copy)
@@ -1,87 +0,0 @@
-/*
- * $Id$
- *
- * Analog Devices ADSP-BF527 SDP board bus driver
- * Copyright (C) 2011 Analog Devices, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- *
- * Written by Jie Zhang <[email protected]>, 2011.
- */
-
-#include "blackfin.h"
-
-typedef struct
-{
-    bfin_bus_params_t params; /* needs to be first */
-    urj_part_signal_t *pg0;   /* ~FLASH_EN */
-} bus_params_t;
-
-#define PG0    ((bus_params_t *) bus->params)->pg0
-
-static void
-bf527_sdp_select_flash (urj_bus_t *bus, uint32_t addr)
-{
-    urj_part_t *part = bus->part;
-
-    urj_part_set_signal (part, PG0, 1, 0);
-}
-
-static void
-bf527_sdp_unselect_flash (urj_bus_t *bus)
-{
-    urj_part_t *part = bus->part;
-
-    urj_part_set_signal (part, PG0, 1, 1);
-}
-
-static urj_bus_t *
-bf527_sdp_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver,
-                   const urj_param_t *cmd_params[])
-{
-    urj_bus_t *bus;
-    urj_part_t *part;
-    bfin_bus_params_t *params;
-    int failed = 0;
-
-    bus = urj_bus_generic_new (chain, driver, sizeof (bus_params_t));
-    if (bus == NULL)
-        return NULL;
-    part = bus->part;
-
-    params = bus->params;
-    params->async_size = 4 * 1024 * 1024;
-    params->ams_cnt = 4;
-    params->abe_cnt = 2;
-    params->addr_cnt = 19;
-    params->data_cnt = 16;
-    params->sdram = 1;
-    params->select_flash = bf527_sdp_select_flash;
-    params->unselect_flash = bf527_sdp_unselect_flash;
-    failed |= bfin_bus_new (bus, cmd_params);
-
-    failed |= urj_bus_generic_attach_sig (part, &PG0, "PG0");
-
-    if (failed)
-    {
-        urj_bus_generic_free (bus);
-        return NULL;
-    }
-
-    return bus;
-}
-
-BFIN_BUS_DECLARE(bf527_sdp, "BF527 SDP board");
------------------------------------------------------------------------------
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better 
price-free! And you'll get a free "Love Thy Logs" t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
_______________________________________________
UrJTAG-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/urjtag-development

Reply via email to