|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 ~! P- w2 v+ K! o# t4 w0 h0 V#include <linux/init.h>8 W/ `# ?. e& s. { |
#include <linux/module.h>" q, D0 n7 Y6 F8 u8 {" e
#include <linux/kernel.h>
# [% x7 m( X3 ?6 y: n& s1 f#include <linux/types.h>, V; h4 t% R1 z5 O4 l- ~4 K
#include <linux/gpio.h>3 y1 J: |6 W5 k5 G
#include <linux/leds.h>
( e+ Y- l1 S# V, @#include <linux/platform_device.h>3 Q$ O0 ?) x! a8 }; c" u
( W/ k- D: [( h
#include <asm/mach-types.h>
$ m z% s- H) D( P* w& f0 v' l#include <asm/mach/arch.h>- B: w" @. U$ _7 [' |8 p+ Z; l5 D
#include <mach/da8xx.h>5 X, e, j* P) t' T- [
#include <mach/mux.h>9 s8 v R4 g0 M; l0 G$ p+ D3 y5 W
5 Y1 v% y/ \9 ~0 u4 ~#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* s. ~. R; E+ m {1 F#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 [" ]8 D( A- f$ s- X+ p, {
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* L" S1 G4 x7 e/ o: J& \
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' N: Y9 F# c1 ^3 z
* R% c" T0 J0 V0 z" \/* assign the tl som board LED-GPIOs*/# F% R8 C9 S" r9 l4 z, g
static const short da850_evm_tl_user_led_pins[] = {& H! }+ ?: ]& Y0 S- ?
/* These pins are definition at <mach/mux.h> file *// @7 ]0 f$ @8 [' h# ^# X2 |
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 T8 X, t5 i+ g' @+ s$ F -1
* M) F+ z$ X& W1 D& H& b};
" I" O' [* R3 y" o6 Y+ D: K1 f' p, ~
: [6 E4 i m0 w' C J$ o, H Zstatic struct gpio_led da850_evm_tl_leds[] = {4 e! f) v2 g( L H3 C# l
{
J- _, `& U. I1 w* J! S .active_low = 0,
3 b. W* \; C C, k1 R .gpio = DA850_USER_LED0,
) A5 D9 Z7 |. J; W! f, e .name = "user_led0",3 @& \8 W" z @- Q& Q! y
.default_trigger = "default-on",
- I1 K' @5 C6 M7 p* U },4 ?/ T, d. r, G H- d O
{
* A u) e: V* k7 a; S) K2 t+ I .active_low = 0,! w. G7 q. o5 _) R4 r! T% c- t
.gpio = DA850_USER_LED1,! c& g: f1 Z# V8 B; J
.name = "user_led1", c3 Q% L8 T' K+ o' M
.default_trigger = "default-on",4 X0 G9 s9 Y" P+ ?: q
},! R) R# @3 ]& U% h9 Z
{
4 E" \6 a+ a) A) {' A .active_low = 0,6 H+ g: |6 u5 l* K) y( Z( [
.gpio = DA850_USER_LED2,5 m2 F( I# v1 a. O3 G
.name = "user_led2",. S* S, X7 y' T7 [0 \/ j' p( a
.default_trigger = "default-on",
' H+ n& j# E* {5 q },3 g; u2 [* K% ^8 N
{1 d! k4 z# g( |
.active_low = 0,# U9 p. A( ~$ e4 ^- a$ P _
.gpio = DA850_USER_LED3,8 L8 T3 k( u- M4 i
.name = "user_led3",7 I# c" N l9 h8 o; q
.default_trigger = "default-on",+ `8 Q2 _7 ]% @
},3 U' n- b& q i- b a4 H1 p
};
4 E- P+ G z7 E3 L* i9 q' ~8 |3 t- {/ r' P; _: x
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 P! _4 |; a, X% y
.leds = da850_evm_tl_leds,
. o0 `4 D: T. a3 w% } .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 o9 `0 B6 k7 K- w% Z};
. `8 F4 q2 i1 w$ J5 H
/ E8 M4 g) Y/ W) X7 `1 a. sstatic void led_dev_release(struct device *dev)% e8 t. i( U! V1 }1 \ ?# L
{
1 j( k, B/ j7 H, {};
1 `, {2 R+ [; {6 V
) q/ k7 C1 b% z# s3 h/ [, j vstatic struct platform_device da850_evm_tl_leds_device = {+ z+ `% F9 @, b" c, n. k: \
.name = "leds-gpio",
# J: g$ g" T& J5 Z7 v' N; @4 O .id = 1,
8 M3 F& R# j9 l( L) v/ h0 @ .dev = {
* b6 D" D0 ^& a0 I6 H1 } .platform_data = &da850_evm_tl_leds_pdata,- e/ r+ g+ K- ?+ j1 R% T
.release = led_dev_release,
8 l3 | W- @: [ }" {& {/ s, {+ l' V* m; l$ D
};
# ]) b5 h+ t4 G. {* E n0 {3 n* [/ O- V5 C" {; H/ ]
static int __init led_platform_init(void)
8 V8 s3 T# n0 Z$ h. G{! S$ c$ J) L3 U0 \$ m; h5 T
int ret;- D* ], p! T( q e$ e8 m9 r) u. W
#if 0
2 `& \1 K5 [: s, E ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" z( ^" \$ w& |& q- Y
if (ret)
2 U5 g% [( A, s } pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" w, h5 s2 d9 _& ^
"%d\n", ret);8 V. K+ L* j2 j
#endif
. J( Y, `, V c3 ^/ M; a+ x- C ret = platform_device_register(&da850_evm_tl_leds_device);
& y; ?" m. |; y2 k$ K if (ret)6 t/ f2 B1 M& I Q3 T! F
pr_warning("Could not register som GPIO expander LEDS");9 O0 Z: m7 }- n
else/ P/ {3 R8 q% Q0 v' P! ^8 f' h* c* q
printk(KERN_INFO "LED register sucessful!\n");
$ g1 y& T. R4 f6 T e
: t i- w) V9 x! N return ret;
0 @& z. |1 ?* o- m; R}# q8 P* x( @" A
4 [" g9 O! P. K9 d+ W M+ B
static void __exit led_platform_exit(void) c( K/ p/ Y& t; k
{
3 V6 g% q" M" s% L4 @- G" X platform_device_unregister(&da850_evm_tl_leds_device);8 I) |$ N. _, f- r" J$ K6 A
; [* N& L+ f8 _4 @% \! ` printk(KERN_INFO "LED unregister!\n");: e5 l$ E7 {. Z; r6 j
}
$ A2 F9 l* C( a5 l, X! d3 h3 r9 G4 Z( D# U
module_init(led_platform_init);
+ ]" o# Q! B1 z* zmodule_exit(led_platform_exit);% J- U# M# k+ ~7 e, ~
! l% p$ ^9 A7 Q/ S4 gMODULE_DESCRIPTION("Led platform driver");- N' O! R3 G X% p, l
MODULE_AUTHOR("Tronlong");
8 `8 J6 W% _$ D6 ]" v! L r, qMODULE_LICENSE("GPL");$ i1 n* G9 B+ Q7 O6 a1 @: J
4 x& K' d- Y; x. N. W1 \ |
|