Date: Sat, 6 Sep 2014 18:08:21 +0000 (UTC) From: Ruslan Bukin <br@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r271200 - head/sys/arm/altera/socfpga Message-ID: <201409061808.s86I8LvX036006@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: br Date: Sat Sep 6 18:08:21 2014 New Revision: 271200 URL: http://svnweb.freebsd.org/changeset/base/271200 Log: o Remove __unused attribute on variables which actually used o Unmagic 'configuration done' bit o Move probe() to place before attach() for better navigation o Use bus_read_n instead of bus_space_read_n functions Pointed out by: andrew Sponsored by: DARPA, AFRL Modified: head/sys/arm/altera/socfpga/socfpga_common.h head/sys/arm/altera/socfpga/socfpga_manager.c Modified: head/sys/arm/altera/socfpga/socfpga_common.h ============================================================================== --- head/sys/arm/altera/socfpga/socfpga_common.h Sat Sep 6 17:50:59 2014 (r271199) +++ head/sys/arm/altera/socfpga/socfpga_common.h Sat Sep 6 18:08:21 2014 (r271200) @@ -30,15 +30,9 @@ * $FreeBSD$ */ -#define READ4(_sc, _reg) \ - bus_space_read_4(_sc->bst, _sc->bsh, _reg) -#define WRITE4(_sc, _reg, _val) \ - bus_space_write_4(_sc->bst, _sc->bsh, _reg, _val) -#define READ2(_sc, _reg) \ - bus_space_read_2(_sc->bst, _sc->bsh, _reg) -#define WRITE2(_sc, _reg, _val) \ - bus_space_write_2(_sc->bst, _sc->bsh, _reg, _val) -#define READ1(_sc, _reg) \ - bus_space_read_1(_sc->bst, _sc->bsh, _reg) -#define WRITE1(_sc, _reg, _val) \ - bus_space_write_1(_sc->bst, _sc->bsh, _reg, _val) +#define READ4(_sc, _reg) bus_read_4((_sc)->res[0], _reg) +#define READ2(_sc, _reg) bus_read_2((_sc)->res[0], _reg) +#define READ1(_sc, _reg) bus_read_1((_sc)->res[0], _reg) +#define WRITE4(_sc, _reg, _val) bus_write_4((_sc)->res[0], _reg, _val) +#define WRITE2(_sc, _reg, _val) bus_write_2((_sc)->res[0], _reg, _val) +#define WRITE1(_sc, _reg, _val) bus_write_1((_sc)->res[0], _reg, _val) Modified: head/sys/arm/altera/socfpga/socfpga_manager.c ============================================================================== --- head/sys/arm/altera/socfpga/socfpga_manager.c Sat Sep 6 17:50:59 2014 (r271199) +++ head/sys/arm/altera/socfpga/socfpga_manager.c Sat Sep 6 18:08:21 2014 (r271200) @@ -91,6 +91,7 @@ __FBSDID("$FreeBSD$"); #define GPIO_PORTA_EOI 0x84C /* Clear Interrupt Register */ #define PORTA_EOI_NS (1 << 0) #define GPIO_EXT_PORTA 0x850 /* External Port A Register */ +#define EXT_PORTA_CDP (1 << 10) /* Configuration done */ #define GPIO_LS_SYNC 0x860 /* Synchronization Level Register */ #define GPIO_VER_ID_CODE 0x86C /* GPIO Version Register */ #define GPIO_CONFIG_REG2 0x870 /* Configuration Register 2 */ @@ -147,8 +148,6 @@ static struct cfgmgr_mode cfgmgr_modes[] struct fpgamgr_softc { struct resource *res[3]; - bus_space_tag_t bst; - bus_space_handle_t bsh; bus_space_tag_t bst_data; bus_space_handle_t bsh_data; struct cdev *mgr_cdev; @@ -163,20 +162,6 @@ static struct resource_spec fpgamgr_spec }; static int -fpgamgr_probe(device_t dev) -{ - - if (!ofw_bus_status_okay(dev)) - return (ENXIO); - - if (!ofw_bus_is_compatible(dev, "altr,fpga-mgr")) - return (ENXIO); - - device_set_desc(dev, "FPGA Manager"); - return (BUS_PROBE_DEFAULT); -} - -static int fpgamgr_state_get(struct fpgamgr_softc *sc) { int reg; @@ -208,7 +193,7 @@ fpgamgr_state_wait(struct fpgamgr_softc } static int -fpga_open(struct cdev *dev __unused, int flags __unused, +fpga_open(struct cdev *dev, int flags __unused, int fmt __unused, struct thread *td __unused) { struct fpgamgr_softc *sc; @@ -310,7 +295,7 @@ fpga_wait_dclk_pulses(struct fpgamgr_sof } static int -fpga_close(struct cdev *dev __unused, int flags __unused, +fpga_close(struct cdev *dev, int flags __unused, int fmt __unused, struct thread *td __unused) { struct fpgamgr_softc *sc; @@ -319,7 +304,7 @@ fpga_close(struct cdev *dev __unused, in sc = dev->si_drv1; reg = READ4(sc, GPIO_EXT_PORTA); - if ((reg & (1 << 10)) == 0) { + if ((reg & EXT_PORTA_CDP) == 0) { device_printf(sc->dev, "Err: configuration failed\n"); return (ENXIO); } @@ -388,6 +373,20 @@ static struct cdevsw fpga_cdevsw = { }; static int +fpgamgr_probe(device_t dev) +{ + + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if (!ofw_bus_is_compatible(dev, "altr,fpga-mgr")) + return (ENXIO); + + device_set_desc(dev, "FPGA Manager"); + return (BUS_PROBE_DEFAULT); +} + +static int fpgamgr_attach(device_t dev) { struct fpgamgr_softc *sc; @@ -401,8 +400,6 @@ fpgamgr_attach(device_t dev) } /* Memory interface */ - sc->bst = rman_get_bustag(sc->res[0]); - sc->bsh = rman_get_bushandle(sc->res[0]); sc->bst_data = rman_get_bustag(sc->res[1]); sc->bsh_data = rman_get_bushandle(sc->res[1]);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201409061808.s86I8LvX036006>