|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" f8 R0 Y) X- C9 }/ _/ z+ n$ K
#include <linux/init.h>
# G4 q% r B g7 i3 k/ E#include <linux/module.h>2 |" E+ n) ~4 f7 k" J
#include <linux/kernel.h>: a D6 [( E M$ M
#include <linux/types.h>4 M G( V. k* p4 M
#include <linux/gpio.h>
4 s, h! m; e+ T" D7 D$ w#include <linux/leds.h>
' s5 R% Q5 e5 d6 ^( r#include <linux/platform_device.h>
8 r$ a0 M: ^, c% ?
" d$ b% h$ y6 F4 q, u1 p#include <asm/mach-types.h>
! B" R' P( m: {" y$ h#include <asm/mach/arch.h>
; P1 d. }9 \/ o, h9 D$ A$ i: D#include <mach/da8xx.h>( o; [7 z/ A8 I
#include <mach/mux.h>
! O r2 \; C$ {% G0 x4 M8 ~$ v7 M1 V" n
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 T% p4 z9 [9 Q' C8 ^6 x9 U9 [
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% N" _8 k1 b8 q L2 W# B4 @
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
G5 N+ d$ s, {4 W9 ]( j: A#define DA850_USER_LED3 GPIO_TO_PIN(0, 2), {+ G" ~( d/ F' y, P" L7 x# w1 a
2 ]. p& W6 a( J3 h1 V/* assign the tl som board LED-GPIOs*/# y( b% M) @# w
static const short da850_evm_tl_user_led_pins[] = {' {3 b6 Z. m8 Q( F" c, O
/* These pins are definition at <mach/mux.h> file */
o$ c# J) b5 K: R: l5 | DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 I6 k7 F+ |2 \ -1; f$ L$ W. p/ u' r( g
};) u+ e: v1 M9 x, c( q* l0 @
1 p* `1 z; c1 X
static struct gpio_led da850_evm_tl_leds[] = {2 n, L" N+ U7 N5 U7 |
{
, @; j- l" E$ C+ I7 v- D .active_low = 0,/ {+ J( x2 N4 g' Y* r: J4 n1 J
.gpio = DA850_USER_LED0,
% I% ^1 F' ~0 r7 | ^: j .name = "user_led0",5 [3 L$ ]% @& i8 r7 y; t6 }; v
.default_trigger = "default-on",4 Z- d2 r, L! w+ u, a
},% G7 W1 T0 F g0 ? ?
{
, _$ {7 y7 F# E' O, U .active_low = 0,
* X& _ P- r- Z' W6 T. S .gpio = DA850_USER_LED1,/ h/ L7 Y3 _9 f. }8 [
.name = "user_led1",/ J1 V! m( A2 r4 D }) ]
.default_trigger = "default-on",
8 q$ ?2 p7 j* ~, R# i8 w# D/ Z9 B },. {7 I5 h4 s3 B
{; X9 r& ?# R0 o4 o+ L4 s: Z' a
.active_low = 0,
8 ?- _. \, [9 m. f/ |/ U .gpio = DA850_USER_LED2,# I. `7 ?( t% D; K$ s9 }9 R( d
.name = "user_led2",
" |8 }5 s7 J3 l B; C/ v# K .default_trigger = "default-on",3 j' c( b |* L0 M: w
},
/ d9 G# c7 o0 H {: i9 t' A2 z( `+ x2 O ]* y
.active_low = 0,/ P8 J! z; `1 b' e4 m) D: h
.gpio = DA850_USER_LED3,
' P1 j* N, R" e8 Y' J .name = "user_led3",
# Q8 o# w$ U2 y' | .default_trigger = "default-on",
& o' m' Q G7 }5 L },
( m( j* _4 s4 q" [};
# z7 r _0 V9 F; I. v/ R) u/ k
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 ^) U% ^' x2 H& z
.leds = da850_evm_tl_leds,' r) H+ u8 D) u& A& V& s% H
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),& y& G, Y/ E [7 m3 S q
};7 A) ]: h3 m, s+ y' ]! @
2 c5 V" ~6 Z2 V' y; p
static void led_dev_release(struct device *dev) ^2 R: L2 u8 A8 Q8 e) o
{
, h7 j5 ]# J$ W7 e& N};
. n+ L# D+ Z4 g, a/ m/ T; B: O0 h( J
static struct platform_device da850_evm_tl_leds_device = {8 C5 e. I' d- @4 n/ _4 {
.name = "leds-gpio",
4 {& I' A2 F" n" A .id = 1,4 d- L& s& s Y. \9 ]; u, I
.dev = {0 ]" u0 b# m; U: Q! p
.platform_data = &da850_evm_tl_leds_pdata,0 e4 Q7 M4 K9 K O! C0 t+ e, h* ~$ Q
.release = led_dev_release,9 ~' {) n6 f+ c# a
}, F5 B. y' D* }' X3 c
};# V+ Z" x+ e; ~& F' o+ p
3 q b9 n2 z& e6 d4 y$ Lstatic int __init led_platform_init(void)
1 I8 q. ~9 _% N7 H( A3 S g{
7 m) }3 u* M" d0 U/ V int ret;+ V$ x6 p4 \8 B- [/ [
#if 0
$ D, w% {2 k m2 @9 s# d: b( H ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( T% @6 N# c7 e6 Q5 O) k if (ret)
# T3 E* n: i/ Z8 r7 W) X9 P pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' M# a- O3 w/ d2 l7 }" ^4 _8 O- C "%d\n", ret);
' P! m% B5 G4 J3 v6 `" b' G0 _: i8 Z#endif. a6 F$ Y, f o& a! C
ret = platform_device_register(&da850_evm_tl_leds_device);
4 l/ J# x4 {4 O d& G if (ret)' n1 m, _# s, a& ^3 \
pr_warning("Could not register som GPIO expander LEDS");% t& K# x B z: v. {+ S; ^' Z
else
% t- `$ q$ \ k2 q) u printk(KERN_INFO "LED register sucessful!\n");
- R" @4 `' A8 E3 h" O: o; |
8 Y$ c/ h/ I: r3 W+ `6 B; f% N return ret;
% i2 H& s, \/ p% o$ R) i}5 U$ H* R; R. k# J: x
9 w: T8 ]+ ^ h3 {/ jstatic void __exit led_platform_exit(void)
- j' q" z( }* d' s/ O{: A7 v/ e: f7 ]
platform_device_unregister(&da850_evm_tl_leds_device);6 S3 F0 X0 \0 C6 u7 a3 j
" H$ {2 u7 p6 g& v+ Q printk(KERN_INFO "LED unregister!\n");
1 j2 q3 c* w1 O4 `}
, E7 l4 D+ |1 X$ ]* E$ P Y- Z% @+ H$ _ e% W3 I2 F3 g
module_init(led_platform_init);: p* Z Q. v6 [* D/ k7 n
module_exit(led_platform_exit);
! @$ W# ?9 s$ N8 a7 T4 c B" j l( O; Y+ t2 T% J2 ^9 o
MODULE_DESCRIPTION("Led platform driver");; y1 p& {2 {: B4 e
MODULE_AUTHOR("Tronlong");
7 r0 e3 t' o, x* n( |- UMODULE_LICENSE("GPL");
" z; O) u3 t; f l; [% Q5 M3 S: a& N3 v
|
|