FreeBSD Bugzilla – Attachment 164293 Details for
Bug 205359
Add support for Advantech PCI-1602 rev B board and PCI-1603
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Support Advantech PCI-1602A, PCI-1602B and PCI-1603 with RS-422 and RS-485 auto-turnaround
advantech-pci1602b.diff (text/plain), 3.58 KB, created by
Jan Martin Mikkelsen
on 2015-12-16 20:51:34 UTC
(
hide
)
Description:
Support Advantech PCI-1602A, PCI-1602B and PCI-1603 with RS-422 and RS-485 auto-turnaround
Filename:
MIME Type:
Creator:
Jan Martin Mikkelsen
Created:
2015-12-16 20:51:34 UTC
Size:
3.58 KB
patch
obsolete
>==== //depot/vendor/freebsd/10.2-official/src/sys/dev/puc/pucdata.c#2 (text) - //depot/vendor/freebsd/10.2-local/src/sys/dev/puc/pucdata.c#2 (text) ==== content >@@ -47,6 +47,7 @@ > #include <dev/puc/puc_cfg.h> > #include <dev/puc/puc_bfe.h> > >+static puc_config_f puc_config_advantech; > static puc_config_f puc_config_amc; > static puc_config_f puc_config_diva; > static puc_config_f puc_config_exar; >@@ -642,12 +643,26 @@ > .config_function = puc_config_exar_pcie > }, > >+ /* >+ * The Advantech PCI-1602 Rev A uses the first two ports of the Oxford >+ * Semiconductor OXuPCI954. Note this board has a hardware bug where >+ * it will drive the RS-485 transmitter after power-on until a driver >+ * initalises the uart. >+ */ > { 0x13fe, 0x1600, 0x1602, 0x0002, >- "Advantech PCI-1602", >+ "Advantech PCI-1602 rev A", > DEFAULT_RCLK * 8, > PUC_PORT_2S, 0x10, 0, 8, > }, > >+ /* Advantech PCI-1602 Rev B and PCI-1603 uses Oxford Semi OXuPCI952 */ >+ { 0x13fe, 0xa102, 0x13fe, 0xa102, >+ "Advantech 2-port PCI (PCI-1602 rev B1 / PCI-1603)", >+ DEFAULT_RCLK * 8, >+ PUC_PORT_2S, 0x10, 4, 0, >+ .config_function = puc_config_advantech >+ }, >+ > { 0x1407, 0x0100, 0xffff, 0, > "Lava Computers Dual Serial", > DEFAULT_RCLK, >@@ -1201,6 +1216,85 @@ > }; > > static int >+puc_config_advantech(struct puc_softc *sc, enum puc_cfg_cmd cmd, int port, >+ intptr_t *res) >+{ >+ /* Advantech sell multiport boards with RS-232 or RS-422/485 ports >+ * that have the same PCI ID. There is a bitmap at offset 0x60 from >+ * BAR 0x10 on PCI function 1 for this board that indicates the port >+ * types, zero is RS-232, one is RS-485. >+ * >+ * These boards have an Oxford Semiconductor OXuPCI952 UART needs to be >+ * configured in the RS-485 case to enable DTR when transmitting and >+ * disable when stopped. For these boards it is active-low, so 0b10 >+ * needs to be written to ACR[4:3]. The other ACR bits can be zero, so >+ * we write 0x10. There are other Advantech boards where this is >+ * active-high, write 0x18 for those boards. I believe they all have >+ * different PCI IDs. >+ * >+ * Jan Mikkelsen >+ * janm@transactionware.com >+ * March 2015 >+ */ >+ >+ const struct puc_cfg *cfg = sc->sc_cfg; >+ struct puc_bar *port_bar; >+ device_t conf_dev; >+ struct resource *conf_res; >+ int conf_rid; >+ int i; >+ uint8_t mask; >+ >+ if (cmd != PUC_CFG_SETUP) >+ return (ENXIO); >+ >+ conf_dev = pci_find_dbsf(pci_get_domain(sc->sc_dev), >+ pci_get_bus(sc->sc_dev), pci_get_slot(sc->sc_dev), 1); >+ >+ if (conf_dev == NULL) { >+ device_printf(sc->sc_dev, >+ "Advantech card, could not find config function\n"); >+ return (ENXIO); >+ } >+ >+ conf_rid = 0x10; >+ conf_res = bus_alloc_resource_any(conf_dev, SYS_RES_IOPORT, &conf_rid, >+ RF_ACTIVE); >+ >+ if (conf_res == NULL) { >+ device_printf(sc->sc_dev, >+ "Advantech card, could allocate config resource\n"); >+ return (ENXIO); >+ } >+ >+ mask = bus_read_1(conf_res, 0x60); >+ >+ bus_release_resource(conf_dev, SYS_RES_IOPORT, conf_rid, conf_res); >+ >+ for (i = 0; i < sc->sc_nports; ++i) { >+ if ((mask & (1 << i)) == 0) { >+ device_printf(sc->sc_dev, "Port %d RS-232\n", i + 1); >+ continue; >+ } >+ >+ port_bar = puc_get_bar(sc, cfg->rid + i * cfg->d_rid); >+ if (port_bar == NULL) { >+ device_printf(sc->sc_dev, "Port %d: could not " >+ "get BAR to set auto-turnaround.\n", i + 1); >+ continue; >+ } >+ >+ device_printf(sc->sc_dev, >+ "Port %d RS-422/RS-485, active-low auto-DTR\n", i + 1); >+ >+ bus_write_1(port_bar->b_res, 7, 0); >+ bus_write_1(port_bar->b_res, 5, 0x10); >+ } >+ >+ return (0); >+} >+ >+static int > puc_config_amc(struct puc_softc *sc, enum puc_cfg_cmd cmd, int port, > intptr_t *res) > {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 205359
: 164293