hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/include/linux/fsl/mc.h
....@@ -3,6 +3,7 @@
33 * Freescale Management Complex (MC) bus public interface
44 *
55 * Copyright (C) 2014-2016 Freescale Semiconductor, Inc.
6
+ * Copyright 2019-2020 NXP
67 * Author: German Rivera <German.Rivera@freescale.com>
78 *
89 */
....@@ -148,6 +149,13 @@
148149 */
149150 #define FSL_MC_IS_DPRC 0x0001
150151
152
+/* Region flags */
153
+/* Indicates that region can be mapped as cacheable */
154
+#define FSL_MC_REGION_CACHEABLE 0x00000001
155
+
156
+/* Indicates that region can be mapped as shareable */
157
+#define FSL_MC_REGION_SHAREABLE 0x00000002
158
+
151159 /**
152160 * struct fsl_mc_device - MC object device object
153161 * @dev: Linux driver model device object
....@@ -161,6 +169,7 @@
161169 * @regions: pointer to array of MMIO region entries
162170 * @irqs: pointer to array of pointers to interrupts allocated to this device
163171 * @resource: generic resource associated with this MC object device, if any.
172
+ * @driver_override: driver name to force a match
164173 *
165174 * Generic device object for MC object devices that are "attached" to a
166175 * MC bus.
....@@ -186,13 +195,15 @@
186195 struct device dev;
187196 u64 dma_mask;
188197 u16 flags;
189
- u16 icid;
198
+ u32 icid;
190199 u16 mc_handle;
191200 struct fsl_mc_io *mc_io;
192201 struct fsl_mc_obj_desc obj_desc;
193202 struct resource *regions;
194203 struct fsl_mc_device_irq **irqs;
195204 struct fsl_mc_resource *resource;
205
+ struct device_link *consumer_link;
206
+ char *driver_override;
196207 };
197208
198209 #define to_fsl_mc_device(_dev) \
....@@ -210,8 +221,8 @@
210221 };
211222
212223 struct fsl_mc_command {
213
- u64 header;
214
- u64 params[MC_CMD_NUM_OF_PARAMS];
224
+ __le64 header;
225
+ __le64 params[MC_CMD_NUM_OF_PARAMS];
215226 };
216227
217228 enum mc_cmd_status {
....@@ -238,11 +249,11 @@
238249 /* Command completion flag */
239250 #define MC_CMD_FLAG_INTR_DIS 0x01
240251
241
-static inline u64 mc_encode_cmd_header(u16 cmd_id,
242
- u32 cmd_flags,
243
- u16 token)
252
+static inline __le64 mc_encode_cmd_header(u16 cmd_id,
253
+ u32 cmd_flags,
254
+ u16 token)
244255 {
245
- u64 header = 0;
256
+ __le64 header = 0;
246257 struct mc_cmd_header *hdr = (struct mc_cmd_header *)&header;
247258
248259 hdr->cmd_id = cpu_to_le16(cmd_id);
....@@ -338,7 +349,7 @@
338349 * This field is only meaningful if the
339350 * FSL_MC_IO_ATOMIC_CONTEXT_PORTAL flag is set
340351 */
341
- spinlock_t spinlock; /* serializes mc_send_command() */
352
+ raw_spinlock_t spinlock; /* serializes mc_send_command() */
342353 };
343354 };
344355
....@@ -350,6 +361,14 @@
350361 /* If fsl-mc bus is not present device cannot belong to fsl-mc bus */
351362 #define dev_is_fsl_mc(_dev) (0)
352363 #endif
364
+
365
+/* Macro to check if a device is a container device */
366
+#define fsl_mc_is_cont_dev(_dev) (to_fsl_mc_device(_dev)->flags & \
367
+ FSL_MC_IS_DPRC)
368
+
369
+/* Macro to get the container device of a MC device */
370
+#define fsl_mc_cont_dev(_dev) (fsl_mc_is_cont_dev(_dev) ? \
371
+ (_dev) : (_dev)->parent)
353372
354373 /*
355374 * module_fsl_mc_driver() - Helper macro for drivers that don't do
....@@ -371,6 +390,22 @@
371390 struct module *owner);
372391
373392 void fsl_mc_driver_unregister(struct fsl_mc_driver *driver);
393
+
394
+/**
395
+ * struct fsl_mc_version
396
+ * @major: Major version number: incremented on API compatibility changes
397
+ * @minor: Minor version number: incremented on API additions (that are
398
+ * backward compatible); reset when major version is incremented
399
+ * @revision: Internal revision number: incremented on implementation changes
400
+ * and/or bug fixes that have no impact on API
401
+ */
402
+struct fsl_mc_version {
403
+ u32 major;
404
+ u32 minor;
405
+ u32 revision;
406
+};
407
+
408
+struct fsl_mc_version *fsl_mc_get_version(void);
374409
375410 int __must_check fsl_mc_portal_allocate(struct fsl_mc_device *mc_dev,
376411 u16 mc_io_flags,
....@@ -394,6 +429,8 @@
394429
395430 void fsl_mc_free_irqs(struct fsl_mc_device *mc_dev);
396431
432
+struct fsl_mc_device *fsl_mc_get_endpoint(struct fsl_mc_device *mc_dev);
433
+
397434 extern struct bus_type fsl_mc_bus_type;
398435
399436 extern struct device_type fsl_mc_bus_dprc_type;
....@@ -405,6 +442,12 @@
405442 extern struct device_type fsl_mc_bus_dpmcp_type;
406443 extern struct device_type fsl_mc_bus_dpmac_type;
407444 extern struct device_type fsl_mc_bus_dprtc_type;
445
+extern struct device_type fsl_mc_bus_dpseci_type;
446
+extern struct device_type fsl_mc_bus_dpdmux_type;
447
+extern struct device_type fsl_mc_bus_dpdcei_type;
448
+extern struct device_type fsl_mc_bus_dpaiop_type;
449
+extern struct device_type fsl_mc_bus_dpci_type;
450
+extern struct device_type fsl_mc_bus_dpdmai_type;
408451
409452 static inline bool is_fsl_mc_bus_dprc(const struct fsl_mc_device *mc_dev)
410453 {
....@@ -424,6 +467,11 @@
424467 static inline bool is_fsl_mc_bus_dpsw(const struct fsl_mc_device *mc_dev)
425468 {
426469 return mc_dev->dev.type == &fsl_mc_bus_dpsw_type;
470
+}
471
+
472
+static inline bool is_fsl_mc_bus_dpdmux(const struct fsl_mc_device *mc_dev)
473
+{
474
+ return mc_dev->dev.type == &fsl_mc_bus_dpdmux_type;
427475 }
428476
429477 static inline bool is_fsl_mc_bus_dpbp(const struct fsl_mc_device *mc_dev)
....@@ -451,6 +499,60 @@
451499 return mc_dev->dev.type == &fsl_mc_bus_dprtc_type;
452500 }
453501
502
+static inline bool is_fsl_mc_bus_dpseci(const struct fsl_mc_device *mc_dev)
503
+{
504
+ return mc_dev->dev.type == &fsl_mc_bus_dpseci_type;
505
+}
506
+
507
+static inline bool is_fsl_mc_bus_dpdcei(const struct fsl_mc_device *mc_dev)
508
+{
509
+ return mc_dev->dev.type == &fsl_mc_bus_dpdcei_type;
510
+}
511
+
512
+static inline bool is_fsl_mc_bus_dpaiop(const struct fsl_mc_device *mc_dev)
513
+{
514
+ return mc_dev->dev.type == &fsl_mc_bus_dpaiop_type;
515
+}
516
+
517
+static inline bool is_fsl_mc_bus_dpci(const struct fsl_mc_device *mc_dev)
518
+{
519
+ return mc_dev->dev.type == &fsl_mc_bus_dpci_type;
520
+}
521
+
522
+static inline bool is_fsl_mc_bus_dpdmai(const struct fsl_mc_device *mc_dev)
523
+{
524
+ return mc_dev->dev.type == &fsl_mc_bus_dpdmai_type;
525
+}
526
+
527
+#define DPRC_RESET_OPTION_NON_RECURSIVE 0x00000001
528
+int dprc_reset_container(struct fsl_mc_io *mc_io,
529
+ u32 cmd_flags,
530
+ u16 token,
531
+ int child_container_id,
532
+ u32 options);
533
+
534
+int dprc_scan_container(struct fsl_mc_device *mc_bus_dev,
535
+ bool alloc_interrupts);
536
+
537
+void dprc_remove_devices(struct fsl_mc_device *mc_bus_dev,
538
+ struct fsl_mc_obj_desc *obj_desc_array,
539
+ int num_child_objects_in_mc);
540
+
541
+int dprc_cleanup(struct fsl_mc_device *mc_dev);
542
+
543
+int dprc_setup(struct fsl_mc_device *mc_dev);
544
+
545
+/**
546
+ * Maximum number of total IRQs that can be pre-allocated for an MC bus'
547
+ * IRQ pool
548
+ */
549
+#define FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS 256
550
+
551
+int fsl_mc_populate_irq_pool(struct fsl_mc_device *mc_bus_dev,
552
+ unsigned int irq_count);
553
+
554
+void fsl_mc_cleanup_irq_pool(struct fsl_mc_device *mc_bus_dev);
555
+
454556 /*
455557 * Data Path Buffer Pool (DPBP) API
456558 * Contains initialization APIs and runtime control APIs for DPBP