@@ -215,6 +215,7 @@ struct ptp_ocp {
215
215
struct irig_slave_reg __iomem * irig_in ;
216
216
struct dcf_master_reg __iomem * dcf_out ;
217
217
struct dcf_slave_reg __iomem * dcf_in ;
218
+ struct tod_reg __iomem * nmea_out ;
218
219
struct ptp_ocp_ext_src * pps ;
219
220
struct ptp_ocp_ext_src * ts0 ;
220
221
struct ptp_ocp_ext_src * ts1 ;
@@ -232,6 +233,7 @@ struct ptp_ocp {
232
233
int n_irqs ;
233
234
int gnss_port ;
234
235
int mac_port ; /* miniature atomic clock */
236
+ int nmea_port ;
235
237
u8 serial [6 ];
236
238
bool has_serial ;
237
239
int flash_start ;
@@ -289,8 +291,9 @@ static int ptp_ocp_ts_enable(void *priv, bool enable);
289
291
* 5: MAC
290
292
* 6: TS2
291
293
* 7: I2C controller
292
- * 8: HWICAP
294
+ * 8: HWICAP (notused)
293
295
* 9: SPI Flash
296
+ * 10: NMEA
294
297
*/
295
298
296
299
static struct ocp_resource ocp_fb_resource [] = {
@@ -353,6 +356,10 @@ static struct ocp_resource ocp_fb_resource[] = {
353
356
OCP_MEM_RESOURCE (dcf_out ),
354
357
.offset = 0x010A0000 , .size = 0x10000 ,
355
358
},
359
+ {
360
+ OCP_MEM_RESOURCE (nmea_out ),
361
+ .offset = 0x010B0000 , .size = 0x10000 ,
362
+ },
356
363
{
357
364
OCP_MEM_RESOURCE (image ),
358
365
.offset = 0x00020000 , .size = 0x1000 ,
@@ -381,6 +388,10 @@ static struct ocp_resource ocp_fb_resource[] = {
381
388
OCP_SERIAL_RESOURCE (mac_port ),
382
389
.offset = 0x00180000 + 0x1000 , .irq_vec = 5 ,
383
390
},
391
+ {
392
+ OCP_SERIAL_RESOURCE (nmea_port ),
393
+ .offset = 0x00190000 + 0x1000 , .irq_vec = 10 ,
394
+ },
384
395
{
385
396
OCP_SPI_RESOURCE (spi_flash ),
386
397
.offset = 0x00310000 , .size = 0x10000 , .irq_vec = 9 ,
@@ -761,6 +772,8 @@ ptp_ocp_utc_distribute(struct ptp_ocp *bp, u32 val)
761
772
iowrite32 (val , & bp -> irig_out -> adj_sec );
762
773
if (bp -> dcf_out )
763
774
iowrite32 (val , & bp -> dcf_out -> adj_sec );
775
+ if (bp -> nmea_out )
776
+ iowrite32 (val , & bp -> nmea_out -> adj_sec );
764
777
765
778
spin_unlock_irqrestore (& bp -> lock , flags );
766
779
}
@@ -1272,13 +1285,25 @@ ptp_ocp_register_mem(struct ptp_ocp *bp, struct ocp_resource *r)
1272
1285
return 0 ;
1273
1286
}
1274
1287
1288
+ static void
1289
+ ptp_ocp_nmea_out_init (struct ptp_ocp * bp )
1290
+ {
1291
+ if (!bp -> nmea_out )
1292
+ return ;
1293
+
1294
+ iowrite32 (0 , & bp -> nmea_out -> ctrl ); /* disable */
1295
+ iowrite32 (7 , & bp -> nmea_out -> uart_baud ); /* 115200 */
1296
+ iowrite32 (1 , & bp -> nmea_out -> ctrl ); /* enable */
1297
+ }
1298
+
1275
1299
/* FB specific board initializers; last "resource" registered. */
1276
1300
static int
1277
1301
ptp_ocp_fb_board_init (struct ptp_ocp * bp , struct ocp_resource * r )
1278
1302
{
1279
1303
bp -> flash_start = 1024 * 4096 ;
1280
1304
1281
1305
ptp_ocp_tod_init (bp );
1306
+ ptp_ocp_nmea_out_init (bp );
1282
1307
1283
1308
return ptp_ocp_init_clock (bp );
1284
1309
}
@@ -1941,6 +1966,13 @@ ptp_ocp_summary_show(struct seq_file *s, void *data)
1941
1966
on ? " ON" : "OFF" , val , src );
1942
1967
}
1943
1968
1969
+ if (bp -> nmea_out ) {
1970
+ on = ioread32 (& bp -> nmea_out -> ctrl ) & 1 ;
1971
+ val = ioread32 (& bp -> nmea_out -> status );
1972
+ seq_printf (s , "%7s: %s, error: %d\n" , "NMEA" ,
1973
+ on ? " ON" : "OFF" , val );
1974
+ }
1975
+
1944
1976
/* compute src for PPS1, used below. */
1945
1977
if (bp -> pps_select ) {
1946
1978
val = ioread32 (& bp -> pps_select -> gpio1 );
@@ -2069,6 +2101,7 @@ ptp_ocp_device_init(struct ptp_ocp *bp, struct pci_dev *pdev)
2069
2101
spin_lock_init (& bp -> lock );
2070
2102
bp -> gnss_port = -1 ;
2071
2103
bp -> mac_port = -1 ;
2104
+ bp -> nmea_port = -1 ;
2072
2105
bp -> pdev = pdev ;
2073
2106
2074
2107
device_initialize (& bp -> dev );
@@ -2134,6 +2167,10 @@ ptp_ocp_complete(struct ptp_ocp *bp)
2134
2167
sprintf (buf , "ttyS%d" , bp -> mac_port );
2135
2168
ptp_ocp_link_child (bp , buf , "ttyMAC" );
2136
2169
}
2170
+ if (bp -> nmea_port != -1 ) {
2171
+ sprintf (buf , "ttyS%d" , bp -> nmea_port );
2172
+ ptp_ocp_link_child (bp , buf , "ttyNMEA" );
2173
+ }
2137
2174
sprintf (buf , "ptp%d" , ptp_clock_index (bp -> ptp ));
2138
2175
ptp_ocp_link_child (bp , buf , "ptp" );
2139
2176
@@ -2180,7 +2217,13 @@ ptp_ocp_serial_info(struct device *dev, const char *name, int port, int baud)
2180
2217
static void
2181
2218
ptp_ocp_info (struct ptp_ocp * bp )
2182
2219
{
2220
+ static int nmea_baud [] = {
2221
+ 1200 , 2400 , 4800 , 9600 , 19200 , 38400 ,
2222
+ 57600 , 115200 , 230400 , 460800 , 921600 ,
2223
+ 1000000 , 2000000
2224
+ };
2183
2225
struct device * dev = & bp -> pdev -> dev ;
2226
+ u32 reg ;
2184
2227
2185
2228
ptp_ocp_phc_info (bp );
2186
2229
if (bp -> tod )
@@ -2199,6 +2242,14 @@ ptp_ocp_info(struct ptp_ocp *bp)
2199
2242
}
2200
2243
ptp_ocp_serial_info (dev , "GNSS" , bp -> gnss_port , 115200 );
2201
2244
ptp_ocp_serial_info (dev , "MAC" , bp -> mac_port , 57600 );
2245
+ if (bp -> nmea_out && bp -> nmea_port != -1 ) {
2246
+ int baud = -1 ;
2247
+
2248
+ reg = ioread32 (& bp -> nmea_out -> uart_baud );
2249
+ if (reg < ARRAY_SIZE (nmea_baud ))
2250
+ baud = nmea_baud [reg ];
2251
+ ptp_ocp_serial_info (dev , "NMEA" , bp -> nmea_port , baud );
2252
+ }
2202
2253
}
2203
2254
2204
2255
static void
@@ -2232,6 +2283,8 @@ ptp_ocp_detach(struct ptp_ocp *bp)
2232
2283
serial8250_unregister_port (bp -> gnss_port );
2233
2284
if (bp -> mac_port != -1 )
2234
2285
serial8250_unregister_port (bp -> mac_port );
2286
+ if (bp -> nmea_port != -1 )
2287
+ serial8250_unregister_port (bp -> nmea_port );
2235
2288
if (bp -> spi_flash )
2236
2289
platform_device_unregister (bp -> spi_flash );
2237
2290
if (bp -> i2c_ctrl )
@@ -2278,7 +2331,7 @@ ptp_ocp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2278
2331
* allow this - if not all of the IRQ's are returned, skip the
2279
2332
* extra devices and just register the clock.
2280
2333
*/
2281
- err = pci_alloc_irq_vectors (pdev , 1 , 10 , PCI_IRQ_MSI | PCI_IRQ_MSIX );
2334
+ err = pci_alloc_irq_vectors (pdev , 1 , 11 , PCI_IRQ_MSI | PCI_IRQ_MSIX );
2282
2335
if (err < 0 ) {
2283
2336
dev_err (& pdev -> dev , "alloc_irq_vectors err: %d\n" , err );
2284
2337
goto out ;
0 commit comments