Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Sep 2008 14:12:50 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        Gavin Atkinson <gavin@freebsd.org>
Cc:        freebsd-acpi@freebsd.org
Subject:   Re: Writing a driver: how do I get resources?
Message-ID:  <200809231412.50418.jhb@freebsd.org>
In-Reply-To: <1222190482.80882.28.camel@buffy.york.ac.uk>
References:  <1222173505.80882.15.camel@buffy.york.ac.uk> <200809231037.00392.jhb@freebsd.org> <1222190482.80882.28.camel@buffy.york.ac.uk>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tuesday 23 September 2008 01:21:22 pm Gavin Atkinson wrote:
> On Tue, 2008-09-23 at 10:36 -0400, John Baldwin wrote:
> > On Tuesday 23 September 2008 08:38:25 am Gavin Atkinson wrote:
> > > Hi all,
> > > 
> > > Please forgive me if this email makes very little sense: I've never
> > > really looked at how ACPI works from a driver's perspective, so don't
> > > really know if what I'm trying to do is even correct.
> > > 
> > > I'm expanding the acpi_sony driver to cover the PNP ID SNY6001.  When I
> > > simply claim it by returning 0 from the probe, I get the following I/O 
> > range:
> > > 
> > > acpi_sony0: <Sony programmable I/O> port 0-0x1f on acpi0
> > > 
> > > However, if I'm reading the AML[1] and Linux drivers[2] correctly, this
> > > is not the correct range.  It appears that the _PRS method offers a
> > > choice of four I/O ranges and four IRQs, one of which is then selected
> > > by evaluating _SRS.  None of them are 0-0x1f.
> > > 
> > > Firstly, does that make sense?  Secondly, how do I do this from a
> > > driver?  I can't see any other drivers that seem to get this involved in
> > > ACPI, indeed the only mention of evaluating _PRS is within the ACPI code
> > > itself.
> > > 
> > > Lastly, I only have intermittent access to this laptop, so I apologise
> > > if I can't test things quickly.
> > 
> > Our ACPI driver isn't smart enough yet (AFAIK) to allocate new resources 
for a 
> > device that doesn't have any.  That logic should be in 
acpi_alloc_resource() 
> > and once that is present then your driver just needs to do the usual 
> > bus_alloc_resource() stuff to work.
> 
> Thanks.  So I guess there's no easy way to do it at the moment?

No. :(  What you would need to do is to change acpi_alloc_resource() such that 
if it is working on a direct child (so device_get_parent(child) == dev) and 
the child has no resources assigned yet, but there are possible resources, it 
needs to allocate a set of resources and do _SRS.

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200809231412.50418.jhb>