Skip to content

Commit 8eaf839

Browse files
NeerajSanjayKaleVudentz
authored andcommitted
serdev: Add method to assert break signal over tty UART port
Adds serdev_device_break_ctl() and an implementation for ttyport. This function simply calls the break_ctl in tty layer, which can assert a break signal over UART-TX line, if the tty and the underlying platform and UART peripheral supports this operation. Signed-off-by: Neeraj Sanjay Kale <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 29f93a6 commit 8eaf839

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

drivers/tty/serdev/core.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,17 @@ int serdev_device_set_tiocm(struct serdev_device *serdev, int set, int clear)
405405
}
406406
EXPORT_SYMBOL_GPL(serdev_device_set_tiocm);
407407

408+
int serdev_device_break_ctl(struct serdev_device *serdev, int break_state)
409+
{
410+
struct serdev_controller *ctrl = serdev->ctrl;
411+
412+
if (!ctrl || !ctrl->ops->break_ctl)
413+
return -EOPNOTSUPP;
414+
415+
return ctrl->ops->break_ctl(ctrl, break_state);
416+
}
417+
EXPORT_SYMBOL_GPL(serdev_device_break_ctl);
418+
408419
static int serdev_drv_probe(struct device *dev)
409420
{
410421
const struct serdev_device_driver *sdrv = to_serdev_device_driver(dev->driver);

drivers/tty/serdev/serdev-ttyport.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,17 @@ static int ttyport_set_tiocm(struct serdev_controller *ctrl, unsigned int set, u
247247
return tty->ops->tiocmset(tty, set, clear);
248248
}
249249

250+
static int ttyport_break_ctl(struct serdev_controller *ctrl, unsigned int break_state)
251+
{
252+
struct serport *serport = serdev_controller_get_drvdata(ctrl);
253+
struct tty_struct *tty = serport->tty;
254+
255+
if (!tty->ops->break_ctl)
256+
return -EOPNOTSUPP;
257+
258+
return tty->ops->break_ctl(tty, break_state);
259+
}
260+
250261
static const struct serdev_controller_ops ctrl_ops = {
251262
.write_buf = ttyport_write_buf,
252263
.write_flush = ttyport_write_flush,
@@ -259,6 +270,7 @@ static const struct serdev_controller_ops ctrl_ops = {
259270
.wait_until_sent = ttyport_wait_until_sent,
260271
.get_tiocm = ttyport_get_tiocm,
261272
.set_tiocm = ttyport_set_tiocm,
273+
.break_ctl = ttyport_break_ctl,
262274
};
263275

264276
struct device *serdev_tty_port_register(struct tty_port *port,

include/linux/serdev.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ struct serdev_controller_ops {
9393
void (*wait_until_sent)(struct serdev_controller *, long);
9494
int (*get_tiocm)(struct serdev_controller *);
9595
int (*set_tiocm)(struct serdev_controller *, unsigned int, unsigned int);
96+
int (*break_ctl)(struct serdev_controller *ctrl, unsigned int break_state);
9697
};
9798

9899
/**
@@ -203,6 +204,7 @@ int serdev_device_write_buf(struct serdev_device *, const unsigned char *, size_
203204
void serdev_device_wait_until_sent(struct serdev_device *, long);
204205
int serdev_device_get_tiocm(struct serdev_device *);
205206
int serdev_device_set_tiocm(struct serdev_device *, int, int);
207+
int serdev_device_break_ctl(struct serdev_device *serdev, int break_state);
206208
void serdev_device_write_wakeup(struct serdev_device *);
207209
int serdev_device_write(struct serdev_device *, const unsigned char *, size_t, long);
208210
void serdev_device_write_flush(struct serdev_device *);
@@ -256,6 +258,10 @@ static inline int serdev_device_set_tiocm(struct serdev_device *serdev, int set,
256258
{
257259
return -EOPNOTSUPP;
258260
}
261+
static inline int serdev_device_break_ctl(struct serdev_device *serdev, int break_state)
262+
{
263+
return -EOPNOTSUPP;
264+
}
259265
static inline int serdev_device_write(struct serdev_device *sdev, const unsigned char *buf,
260266
size_t count, unsigned long timeout)
261267
{

0 commit comments

Comments
 (0)