Commit Graph

73 Commits

Author SHA1 Message Date
Marcel Moolenaar
bfa307a39c Be slightly more paranoid about using the divisor in a division and
the calculated baudrate. Neither should be 0.
2004-11-15 00:00:24 +00:00
Marcel Moolenaar
d8518925d0 Implement UART_IOCTL_BAUD. Consequently, when the baudrate was unset
for the console, we emit the actual baudrate during bus enumeration.
2004-11-14 23:31:19 +00:00
Marcel Moolenaar
54e2bcc7ad Add UART_IOCTL_BAUD to allow us to query the hardware about the
current baudrate setting. Use this ioctl() when we don't know the
baudrate of the sysdev (as represented by a 0 value). When the
ioctl() fails, e.g. when the backend hasn't implemented it or the
hardware doesn't provide the means to determine its current baudrate
setting, we invalidate the baudrate setting by setting it to -1.
None of the backends currently implement the new ioctl().
2004-11-14 23:12:14 +00:00
Marcel Moolenaar
ecf4dc2505 Make sure the baudrate specified with the BR tag is somewhat sane.
A baudrate we consider insane is silently replaced with 0. When the
baudrate is 0, we will not try to program the hardware. Instead we
leave the communication speed unaltered, maximizing the chance to
have a working console. Obviously this means we allow specifying a
0 baudrate for exactly that purpose.
2004-11-14 21:38:22 +00:00
Poul-Henning Kamp
fbbec42fe4 Remove asserts which are not correct if the port is a tty. 2004-10-12 21:00:19 +00:00
Poul-Henning Kamp
79a8d927d3 Use generic tty code instead of (comparatively little) local copies. 2004-10-12 08:22:31 +00:00
Poul-Henning Kamp
9e51d6f15d Use tty->t_sc to find out softc. 2004-09-18 16:43:44 +00:00
Poul-Henning Kamp
a45b36ad47 Use ttyalloc() instead of ttymalloc(NULL) 2004-09-17 07:28:07 +00:00
Marius Strobl
8f0882f544 Don't call uart_bus_probe() for non-matching PnP-devices. Trying to probe
the keyboard controller with uart_bus_probe() caused a hang here on an i386
machine.

Approved by:	marcel
2004-08-25 22:15:33 +00:00
Marius Strobl
115e9ac656 Fix a style(9) bug (variable definitions inside a nested scope) a patch
of mine introduced in revision 1.10.

Approved by:	marcel
Prodded by:	marcel
2004-08-15 02:17:20 +00:00
Marius Strobl
efa79eb77e - Introduce an uart_cpu_identify() which is implemented in uart_cpu_<arch>.c
and that can be used as an identify function for all kinds of busses on a
  certain platform. Expect for sparc64 these are only stubs right now. [1]
- For sparc64, add code to its uart_cpu_identify() for registering the on-
  board ISA UARTs and their resources based on information obtained from
  Open Firmware.
  It would be better if this would be done in the OFW ISA code. However, due
  to the common FreeBSD ISA code and PNP-IDs not always being present in the
  properties of the ISA nodes there seems to be no good way to implement that.
  Therefore special casing UARTs as the sole really relevant ISA devices on
  sparc64 seemed reasonable. [2]

Approved by:	marcel
Discussed with:	marcel [1], tmm [2]
Tested by:	make universe
2004-08-14 23:54:27 +00:00
Marius Strobl
26280d88d7 - Introduce an ofw_bus kobj-interface for retrieving the OFW node and a
subset ("compatible", "device_type", "model" and "name") of the standard
  properties in drivers for devices on Open Firmware supported busses. The
  standard properties "reg", "interrupts" und "address" are not covered by
  this interface because they are only of interest in the respective bridge
  code. There's a remaining standard property "status" which is unclear how
  to support properly but which also isn't used in FreeBSD at present.
  This ofw_bus kobj-interface allows to replace the various (ebus_get_node(),
  ofw_pci_get_node(), etc.) and partially inconsistent (central_get_type()
  vs. sbus_get_device_type(), etc.) existing IVAR ones with a common one.
  This in turn allows to simplify and remove code-duplication in drivers for
  devices that can hang off of more than one OFW supported bus.
- Convert the sparc64 Central, EBus, FHC, PCI and SBus bus drivers and the
  drivers for their children to use the ofw_bus kobj-interface. The IVAR-
  interfaces of the Central, EBus and FHC are entirely replaced by this. The
  PCI bus driver used its own kobj-interface and now also uses the ofw_bus
  one. The IVARs special to the SBus, e.g. for retrieving the burst size,
  remain.
  Beware: this causes an ABI-breakage for modules of drivers which used the
  IVAR-interfaces, i.e. esp(4), hme(4), isp(4) and uart(4), which need to be
  recompiled.
  The style-inconsistencies introduced in some of the bus drivers will be
  fixed by tmm@ in a generic clean-up of the respective drivers later (he
  requested to add the changes in the "new" style).
- Convert the powerpc MacIO bus driver and the drivers for its children to
  use the ofw_bus kobj-interface. This invloves removing the IVARs related
  to the "reg" property which were unused and a leftover from the NetBSD
  origini of the code. There's no ABI-breakage caused by this because none
  of these driver are currently built as modules.
  There are other powerpc bus drivers which can be converted to the ofw_bus
  kobj-interface, e.g. the PCI bus driver, which should be done together
  with converting powerpc to use the OFW PCI code from sparc64.
- Make the SBus and FHC front-end of zs(4) and the sparc64 eeprom(4) take
  advantage of the ofw_bus kobj-interface and simplify them a bit.

Reviewed by:	grehan, tmm
Approved by:	re (scottl)
Discussed with:	tmm
Tested with:	Sun AX1105, AXe, Ultra 2, Ultra 60; PPC cross-build on i386
2004-08-12 17:41:33 +00:00
Marcel Moolenaar
dc70e792a6 Do not use hardware flow control for the moment. There are some issues
with it that need to be understood better before they can be resolved.
This takes time and time is already in short supply.

Reported & tested by: glebius@
2004-08-06 15:51:31 +00:00
Marcel Moolenaar
d882cf921f When sizing the FIFO, don't count all the way up to 1030 if any FIFO
size larger than 128 is considered an incompatible size. Stop counting
when we reach 130 in the loop.
2004-07-26 03:54:40 +00:00
Poul-Henning Kamp
672c05d49c Preparation commit for the tty cleanups that will follow in the near
future:

rename ttyopen() -> tty_open() and ttyclose() -> tty_close().

We need the ttyopen() and ttyclose() for the new generic cdevsw
functions for tty devices in order to have consistent naming.
2004-07-15 20:47:41 +00:00
Marcel Moolenaar
591bc192b3 Update for the KDB framework:
o  Call kdb_enter() instead of breakpoint().
o  Call kdb_alt_break() instead of db_alt_break().
o  Make debugging code conditional upon KDB instead of DDB.
2004-07-10 21:16:01 +00:00
Marcel Moolenaar
89438367ae Add support for uart(4) being a debug port for the GDB backend. 2004-07-10 18:08:38 +00:00
Poul-Henning Kamp
b4994e318a Define the tty methods as typedefs.
Change the return type for t_break to void.

Add t_ioctl (more about this later).
2004-06-30 21:38:08 +00:00
Poul-Henning Kamp
96df2b0bfb Use generic support for BREAK and modem control ioctls. 2004-06-25 10:54:05 +00:00
Poul-Henning Kamp
28710806cb Use the new serial port definitions for modemsignals. 2004-06-24 10:07:28 +00:00
Poul-Henning Kamp
ee531086ca save a few redundant lines by moving the retry loop further backwards. 2004-06-23 10:28:09 +00:00
Poul-Henning Kamp
89c9c53da0 Do the dreaded s/dev_t/struct cdev */
Bump __FreeBSD_version accordingly.
2004-06-16 09:47:26 +00:00
Poul-Henning Kamp
2140d01b27 Machine generated patch which changes linedisc calls from accessing
linesw[] directly to using the ttyld...() functions

The ttyld...() functions ar inline so there is no performance hit.
2004-06-04 16:02:56 +00:00
Poul-Henning Kamp
e451f9b758 Make the remaining serial drivers call ttyioctl() rather than calling
the linedisc directly.
2004-06-04 08:02:37 +00:00
Poul-Henning Kamp
186f2b9e04 Add missing <sys/module.h> includes currently relying on nested include
in <sys/kernel.h>
2004-06-03 06:10:02 +00:00
Warner Losh
2e31e339d1 Fix disordering of pccarddevs.h noticed by bde. Also remove a few
redundant includes and fix some of the include disordering.

Submitted by: bde
2004-05-27 03:49:45 +00:00
Thomas Moestl
89eef2de47 It seems that clearing the MCR_IE bit in the modem control register
does not reliably prevent the triggering of interrupts for all supported
configurations. Thus, the FIFO size probe could cause an interrupt,
which could lead to an interrupt storm in the shared interrupt case.

To prevent this, change ns8250_bus_probe() to use the overflow bit in
the line status register instead of the RX ready bit in the interrupt
identification register to detect whether the FIFO has filled up.
This allows us to clear all bits in the interrupt enable register during
the probe, which should prevent interrupts reliably.
Additionally, the detected FIFO size may be a bit more accurate, because
the overflow bit is only set when the FIFO did actually fill up, while
interrupts would trigger a bit early.

Reviewed and tested on a lot of hardware by:	marcel
2004-05-26 21:59:01 +00:00
Warner Losh
dba6dd177b Move to generating pccarddevs.h on the fly, both for the kernel and
the modules.

Also generate usbdevs.h automatically now, but a non-kernel file is
stopping that at the moment.
2004-05-26 00:53:10 +00:00
Yoshihiro Takahashi
d385ba7313 - Initialize uart_bus_space_io and uart_bus_space_mem.
- Fix wrong comment.
2004-05-16 14:12:05 +00:00
Marcel Moolenaar
eced428604 Fix hangs caused by z8530_bus_ipend() returning UART_IPEND_TXIDLE
not as a pending interrupt status, but as a matter of status quo.
Consequently, when there's no data to be transmitted the condition
is not cleared and uart_intr() is stuck in an infinite loop trying
to clear the UART_IPEND_TXIDLE status.
The z8530_bus_ipend() function is changed to return idle only once
after having sent any data.

The root cause for this problem is that we cannot use the interrupt
status bits of the SCC itself. The register that holds the interrupt
status can only be accessed by channel A and holds the status for
both channels. Using the interrupt status register would complicate
the driver because we need to synchronize access to the SCC between
the channels.

Elementary testing: marius
2004-05-04 06:58:10 +00:00
Marcel Moolenaar
5918c72d28 When the interrupt cannot be INTR_FAST, it still is INTR_MPSAFE.
Mark it as such.
2004-05-04 05:54:02 +00:00
Marcel Moolenaar
b4f00e0bb7 Don't mask TCD in IMR0 when we initialize the channel. Doing so makes
it impossible to check the interrupt status bit when we try to get a
character in the low level console code.
2004-04-25 04:30:40 +00:00
Marcel Moolenaar
f987d8d1d6 To quote submitter:
"... uart_cpu_sparc64.c currently only looks at /options if ttyX is
the selected console. However, there's one case where it should
additionally look at /chosen. If "keyboard" is the selected input-
device and "screen" the output-device (both via /options) but the
keyboard is unplugged, OF automatically switches to ttya for the
console. It even prints a line telling so on "screen". Solaris
respects this behaviour and uses ttya as the console in this case
and people probably expect FreeBSD to do the same (it's also very
handy to temporarily switch consoles)..."

Submitted by: Marius Strobl <marius@alchemy.franken.de>
Has no doubt the change is correct: marcel
2004-04-04 05:06:26 +00:00
Marcel Moolenaar
e5a88925de In uart_ebus_probe(), match "su_pnp" besides "su" for ns8250 family
of UARTs. We already did this in uart_cpu_getdev().
While here, also check the compat name for "su" or "su16550".

Both changes submitted by: Marius Strobl <marius@alchemy.franken.de>
Does not doubt the correctness of the second change: marcel
2004-04-03 23:02:02 +00:00
Marcel Moolenaar
4e55f7230a In ns8250_putc() insert a barrier between writing the character and
checking for transmitter empty.
2004-04-02 07:37:28 +00:00
Marcel Moolenaar
16283d130f Allow the selection of a debug port with hw.uart.dbgport. Unlike
other architectures (like ia64), the variable has to be set to
an OpenFirmware device name.
2004-04-02 07:33:35 +00:00
Marcel Moolenaar
af81ff3f49 Call kbd_attach() only when KBD_INSTALL_CDEV is enabled as the function
is only defined in that case.
2004-04-02 05:59:06 +00:00
Marcel Moolenaar
139a40ebfe Fix braino in previous commit: getenv() can return NULL. 2004-03-20 08:38:33 +00:00
Marcel Moolenaar
2ae4f1fd16 Introduce the hw.uart.console and hw.uart.dbgport environment variables
to select a serial console and debug port (resp). On ia64 these replace
the use of hints completely and take precedence over hints on alpha,
amd64 and i386. On sparc64 these variables are not yet recognised.

The reasons for introducing these variables are:
1.  Hints have side-effects. They reserve the unit number for use by
    isa or acpi devices and therefore cannot be used to select a pci
    device. Also, the use of a unit number to select a device prior
    to bus enumeration is nonsense. The new variables have no side-
    effects and are not based on unit numbers.
2.  Hints don't have the expression power to allow the sysadmin to
    select UARTs that are not legacy PC devices and need the support
    of compile-time constants to give the sysadmin some level of
    flexibility.

The hw.uart.console and hw.uart.dbgport variables specify a list of
attributes. An attribute is a tag-value pair, seperated by a colon.
Attributes are seperated by a comma. Where possible, tags are the
same as those in /etc/remote (only br and pa in practice). Details
can be found in the manpage (not part of this commit).

Not tested on: amd64, pc98
2004-03-20 02:14:02 +00:00
Nate Lawson
5f96beb9e0 Convert callers to the new bus_alloc_resource_any(9) API.
Submitted by:	Mark Santcroos <marks@ripe.net>
Reviewed by:	imp, dfr, bde
2004-03-17 17:50:55 +00:00
Poul-Henning Kamp
dc08ffec87 Device megapatch 4/6:
Introduce d_version field in struct cdevsw, this must always be
initialized to D_VERSION.

Flip sense of D_NOGIANT flag to D_NEEDGIANT, this involves removing
four D_NOGIANT flags and adding 145 D_NEEDGIANT flags.
2004-02-21 21:10:55 +00:00
Poul-Henning Kamp
8e1f1df080 Device megapatch 3/6:
Add missing D_TTY flags to various drivers.

Complete asserts that dev_t's passed to ttyread(), ttywrite(),
ttypoll() and ttykqwrite() have (d_flags & D_TTY) and a struct tty
pointer.

Make ttyread(), ttywrite(), ttypoll() and ttykqwrite() the default
cdevsw methods for D_TTY drivers and remove the explicit initializations
in various drivers cdevsw structures.
2004-02-21 20:41:11 +00:00
Poul-Henning Kamp
e618d9ea2d Use standard style for cdevsw initializtion 2004-02-14 20:01:24 +00:00
Marcel Moolenaar
b662bdc270 Test the return value of UART_PARAM(). Invalid line parameters did not
result in an error before.

PR: kern/60284
Submitted by: Thomas Sandford <freebsduser@paradisegreen.co.uk>
2004-02-14 05:54:39 +00:00
Warner Losh
347934fa63 Sometimes cardbus attachments don't attach, so while we track down
this problem put these lines back in.  While they should be
unnecessary, they appear to be sometimes necessary.

Reviewed in concept: dfr
Approved by: re (scottl@)
2003-11-28 05:28:29 +00:00
Jake Burkholder
d2f154c95e Add a uart attachment/syscons keyboard driver for sun keyboards. In theory
this will work with any uart backend, currently supported hardware uses
either ns8250 or z8530.
2003-11-11 07:33:24 +00:00
Jake Burkholder
d8c43e4c41 Allow uart to attach to keyboards that are not the firmware's notion of
stdin, such as when using a serial console.  We must recognize these
devices here so that we can override the tty attach routine.
2003-11-11 06:52:04 +00:00
Doug Rabson
0be389f3ca Remove explicit cardbus attachments from drivers where this is identical
to the pci attachment. Cardbus is a derived class of pci so all pci
drivers are automatically available for matching against cardbus devices.

Reviewed by: imp
2003-11-03 09:22:18 +00:00
Warner Losh
d25d7d01be Include pccard/pccard_cis.h here too 2003-10-07 04:26:14 +00:00
Marcel Moolenaar
6dcf0a53d2 Don't explicitly initialize d_maj in the cdevsw with MAJOR_AUTO, as
per the intentions of conf.h, rev 1.176. This change is a no-op as
MAJOR_AUTO equals to 0.
2003-09-28 18:20:42 +00:00