Remove everything related to channels from the pwmc public interface, now
that there is a pwmc(4) instance per channel and the channel number is maintained as a driver ivar rather than being passed in from userland.
This commit is contained in:
parent
e68fcc8875
commit
780c3de886
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=349164
@ -71,18 +71,12 @@ pwm_ioctl(struct cdev *dev, u_long cmd, caddr_t data,
|
|||||||
struct pwmc_softc *sc;
|
struct pwmc_softc *sc;
|
||||||
struct pwm_state state;
|
struct pwm_state state;
|
||||||
device_t bus;
|
device_t bus;
|
||||||
u_int nchannel;
|
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
|
||||||
sc = dev->si_drv1;
|
sc = dev->si_drv1;
|
||||||
bus = device_get_parent(sc->dev);
|
bus = device_get_parent(sc->dev);
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case PWMMAXCHANNEL:
|
|
||||||
nchannel = 0;
|
|
||||||
rv = PWMBUS_CHANNEL_COUNT(bus, &nchannel);
|
|
||||||
bcopy(&nchannel, data, sizeof(nchannel));
|
|
||||||
break;
|
|
||||||
case PWMSETSTATE:
|
case PWMSETSTATE:
|
||||||
bcopy(data, &state, sizeof(state));
|
bcopy(data, &state, sizeof(state));
|
||||||
rv = PWMBUS_CHANNEL_CONFIG(bus, sc->chan,
|
rv = PWMBUS_CHANNEL_CONFIG(bus, sc->chan,
|
||||||
|
@ -34,7 +34,6 @@
|
|||||||
#define PWM_POLARITY_INVERTED (1 << 0)
|
#define PWM_POLARITY_INVERTED (1 << 0)
|
||||||
|
|
||||||
struct pwm_state {
|
struct pwm_state {
|
||||||
u_int channel;
|
|
||||||
u_int period;
|
u_int period;
|
||||||
u_int duty;
|
u_int duty;
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
@ -45,9 +44,8 @@ struct pwm_state {
|
|||||||
* ioctls
|
* ioctls
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PWMMAXCHANNEL _IOWR('G', 0, int)
|
#define PWMGETSTATE _IOWR('G', 0, struct pwm_state)
|
||||||
#define PWMGETSTATE _IOWR('G', 1, struct pwm_state)
|
#define PWMSETSTATE _IOWR('G', 1, struct pwm_state)
|
||||||
#define PWMSETSTATE _IOWR('G', 2, struct pwm_state)
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* _PWM_H_ */
|
#endif /* _PWM_H_ */
|
||||||
|
@ -31,23 +31,18 @@
|
|||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl f Ar device
|
.Op Fl f Ar device
|
||||||
.Fl c Ar channel
|
|
||||||
.Fl E
|
.Fl E
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl f Ar device
|
.Op Fl f Ar device
|
||||||
.Fl c Ar channel
|
|
||||||
.Fl D
|
.Fl D
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl f Ar device
|
.Op Fl f Ar device
|
||||||
.Fl c Ar channel
|
|
||||||
.Fl C
|
.Fl C
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl f Ar device
|
.Op Fl f Ar device
|
||||||
.Fl c Ar channel
|
|
||||||
.Fl p Ar period
|
.Fl p Ar period
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl f Ar device
|
.Op Fl f Ar device
|
||||||
.Fl c Ar channel
|
|
||||||
.Fl d Ar duty
|
.Fl d Ar duty
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
The
|
The
|
||||||
@ -55,9 +50,7 @@ The
|
|||||||
utility can be used to configure pwm controllers.
|
utility can be used to configure pwm controllers.
|
||||||
.Pp
|
.Pp
|
||||||
The options are as follow:
|
The options are as follow:
|
||||||
.Bl -tag -width "-c channel"
|
.Bl -tag -width "-f device"
|
||||||
.It Fl c Ar channel
|
|
||||||
Channel number to operate on.
|
|
||||||
.It Fl f Ar device
|
.It Fl f Ar device
|
||||||
Device to operate on.
|
Device to operate on.
|
||||||
If not specified,
|
If not specified,
|
||||||
|
@ -66,11 +66,11 @@ static void
|
|||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage:\n");
|
fprintf(stderr, "Usage:\n");
|
||||||
fprintf(stderr, "\tpwm [-f dev] -c channel -E\n");
|
fprintf(stderr, "\tpwm [-f dev] -E\n");
|
||||||
fprintf(stderr, "\tpwm [-f dev] -c channel -D\n");
|
fprintf(stderr, "\tpwm [-f dev] -D\n");
|
||||||
fprintf(stderr, "\tpwm [-f dev] -c channel -C\n");
|
fprintf(stderr, "\tpwm [-f dev] -C\n");
|
||||||
fprintf(stderr, "\tpwm [-f dev] -c channel -p period\n");
|
fprintf(stderr, "\tpwm [-f dev] -p period\n");
|
||||||
fprintf(stderr, "\tpwm [-f dev] -c channel -d duty\n");
|
fprintf(stderr, "\tpwm [-f dev] -d duty\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,21 +79,19 @@ main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
struct pwm_state state;
|
struct pwm_state state;
|
||||||
int fd;
|
int fd;
|
||||||
u_int channel, nchannels;
|
|
||||||
int period, duty;
|
int period, duty;
|
||||||
int action, ch;
|
int action, ch;
|
||||||
cap_rights_t right_ioctl;
|
cap_rights_t right_ioctl;
|
||||||
const unsigned long pwm_ioctls[] = {PWMGETSTATE, PWMSETSTATE, PWMMAXCHANNEL};
|
const unsigned long pwm_ioctls[] = {PWMGETSTATE, PWMSETSTATE};
|
||||||
char *percent;
|
char *percent;
|
||||||
bool setname;
|
bool setname;
|
||||||
|
|
||||||
action = 0;
|
action = 0;
|
||||||
setname = false;
|
setname = false;
|
||||||
fd = -1;
|
fd = -1;
|
||||||
channel = -1u;
|
|
||||||
period = duty = -1;
|
period = duty = -1;
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "f:c:EDCp:d:")) != -1) {
|
while ((ch = getopt(argc, argv, "f:EDCp:d:")) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'E':
|
case 'E':
|
||||||
if (action)
|
if (action)
|
||||||
@ -124,15 +122,13 @@ main(int argc, char *argv[])
|
|||||||
if (*percent != '\0' && *percent != '%')
|
if (*percent != '\0' && *percent != '%')
|
||||||
usage();
|
usage();
|
||||||
break;
|
break;
|
||||||
case 'c':
|
|
||||||
if (channel != -1u)
|
|
||||||
usage();
|
|
||||||
channel = strtoul(optarg, NULL, 10);
|
|
||||||
break;
|
|
||||||
case 'f':
|
case 'f':
|
||||||
setname = true;
|
setname = true;
|
||||||
set_device_name(optarg);
|
set_device_name(optarg);
|
||||||
break;
|
break;
|
||||||
|
case '?':
|
||||||
|
usage();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,19 +163,7 @@ main(int argc, char *argv[])
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if the channel is correct */
|
|
||||||
if (ioctl(fd, PWMMAXCHANNEL, &nchannels) == -1) {
|
|
||||||
fprintf(stderr, "ioctl: %s\n", strerror(errno));
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
if (channel > nchannels) {
|
|
||||||
fprintf(stderr, "pwm controller only support %d channels\n",
|
|
||||||
nchannels);
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Fill the common args */
|
/* Fill the common args */
|
||||||
state.channel = channel;
|
|
||||||
if (ioctl(fd, PWMGETSTATE, &state) == -1) {
|
if (ioctl(fd, PWMGETSTATE, &state) == -1) {
|
||||||
fprintf(stderr, "Cannot get current state of the pwm controller\n");
|
fprintf(stderr, "Cannot get current state of the pwm controller\n");
|
||||||
goto fail;
|
goto fail;
|
||||||
|
Loading…
Reference in New Issue
Block a user