return 0;
}
+static int str_to_dpll_pin_direction(const char *dir_str, __u32 *direction)
+{
+ int num;
+
+ num = str_map_lookup_str(pin_direction_map, dir_str);
+ if (num < 0)
+ return num;
+ *direction = num;
+ return 0;
+}
+
static int str_to_dpll_pin_type(const char *type_str, __u32 *type)
{
int num;
#define DPLL_FILTER_PIN_TYPE BIT(5)
#define DPLL_FILTER_PIN_PARENT_DEVICE BIT(6)
#define DPLL_FILTER_PIN_PARENT_PIN BIT(7)
+#define DPLL_FILTER_PIN_DIRECTION BIT(8)
+#define DPLL_FILTER_PIN_STATE BIT(9)
struct dpll_pin_filter {
uint64_t present;
__u32 type;
__u32 parent_device_id;
__u32 parent_pin_id;
+ __u32 direction;
+ __u32 state;
};
static bool filter_match_nested_id(const struct nlmsghdr *nlh,
return false;
}
+static bool filter_match_nested_parent_device(const struct nlmsghdr *nlh,
+ struct dpll_pin_filter *filter)
+{
+ const struct nlattr *attr;
+
+ mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
+ struct nlattr *tb_nest[DPLL_A_PIN_MAX + 1] = {};
+
+ if (mnl_attr_get_type(attr) != DPLL_A_PIN_PARENT_DEVICE)
+ continue;
+
+ mnl_attr_parse_nested(attr, attr_pin_cb, tb_nest);
+
+ if ((filter->present & DPLL_FILTER_PIN_PARENT_DEVICE) &&
+ !filter_match_u32(tb_nest[DPLL_A_PIN_PARENT_ID],
+ filter->parent_device_id))
+ continue;
+
+ if ((filter->present & DPLL_FILTER_PIN_DIRECTION) &&
+ !filter_match_u32(tb_nest[DPLL_A_PIN_DIRECTION],
+ filter->direction))
+ continue;
+
+ if ((filter->present & DPLL_FILTER_PIN_STATE) &&
+ !filter_match_u32(tb_nest[DPLL_A_PIN_STATE],
+ filter->state))
+ continue;
+
+ return true;
+ }
+ return false;
+}
+
static bool dpll_pin_dump_filter(struct dpll_pin_filter *filter,
const struct nlmsghdr *nlh,
struct nlattr **tb)
if ((filter->present & DPLL_FILTER_PIN_TYPE) &&
!filter_match_u32(tb[DPLL_A_PIN_TYPE], filter->type))
return false;
- if ((filter->present & DPLL_FILTER_PIN_PARENT_DEVICE) &&
- !filter_match_nested_id(nlh, DPLL_A_PIN_PARENT_DEVICE,
- filter->parent_device_id))
+ if ((filter->present & (DPLL_FILTER_PIN_PARENT_DEVICE |
+ DPLL_FILTER_PIN_DIRECTION |
+ DPLL_FILTER_PIN_STATE)) &&
+ !filter_match_nested_parent_device(nlh, filter))
return false;
if ((filter->present & DPLL_FILTER_PIN_PARENT_PIN) &&
!filter_match_nested_id(nlh, DPLL_A_PIN_PARENT_PIN,
str_to_dpll_pin_type,
"mux/ext/synce-eth-port/int-oscillator/gnss"))
return -EINVAL;
+ } else if (dpll_argv_match(dpll, "direction")) {
+ if (dpll_filter_parse_enum(dpll, "direction",
+ &filter.direction,
+ &filter.present,
+ DPLL_FILTER_PIN_DIRECTION,
+ str_to_dpll_pin_direction,
+ "input/output"))
+ return -EINVAL;
+ } else if (dpll_argv_match(dpll, "state")) {
+ if (dpll_filter_parse_enum(dpll, "state",
+ &filter.state,
+ &filter.present,
+ DPLL_FILTER_PIN_STATE,
+ str_to_dpll_pin_state,
+ "connected/disconnected/selectable"))
+ return -EINVAL;
} else {
pr_err("unknown option: %s\n", dpll_argv(dpll));
return -EINVAL;
.SH PIN COMMANDS
-.SS dpll pin show [ id ID ] [ parent-device DEVICE_ID ] [ parent-pin PIN_ID ] [ module-name NAME ] [ clock-id ID ] [ board-label LABEL ] [ panel-label LABEL ] [ package-label LABEL ] [ type TYPE ]
+.SS dpll pin show [ id ID ] [ parent-device DEVICE_ID ] [ parent-pin PIN_ID ] [ module-name NAME ] [ clock-id ID ] [ board-label LABEL ] [ panel-label LABEL ] [ package-label LABEL ] [ type TYPE ] [ direction DIR ] [ state STATE ]
Display information about DPLL pins. If no arguments are specified,
shows all pins in the system.
Show only pins of the specified type:
.BR mux ", " ext ", " synce-eth-port ", " int-oscillator ", " gnss .
+.TP
+.BI direction " DIR"
+Show only pins that have a parent-device relationship with the specified direction:
+.BR input ", " output .
+When combined with
+.BR parent-device ,
+only the specified parent-device relationship is checked.
+
+.TP
+.BI state " STATE"
+Show only pins that have a parent-device relationship with the specified state:
+.BR connected ", " disconnected ", " selectable .
+When combined with
+.BR parent-device ,
+only the specified parent-device relationship is checked.
+
.PP
Output includes:
.RS
.B dpll -jp pin show id 5
.fi
+.SS Show connected input pins on device 0
+.nf
+.B dpll pin show parent-device 0 direction input state connected
+.fi
+
.SS Set pin frequency to 10 MHz
.nf
.B dpll pin set id 0 frequency 10000000